
Prisma 초기화npx prisma init --datasource-provider postgresql.env 파일에서windows의 경우 [postgres:password]로 변경하고, mydb를 생성할 db 이름 입력DATABASE_URL="postgresql://postgres:password@localhost:5432/comazon?schema=public"PORT=3000 User 모델 만들기// @id, @unique: 유니크한 값// @default(uuid()): uuid - 36자로 이뤄진 형식// ? : 값을 비워놔도 된다는 의미... NULL로 표시model User { id String @id email String @unique firstName Stri..
스키마 정의하기스키마: 데이터의 틀import mongoose from "mongoose";const TaskSchema = new mongoose.Schema( { titile: { type: String, }, description: { type: String, }, siComplete: { type: Boolean, default: false, }, }, { // timestamps 사용시 mongo가 알아서 create, update app 필드를 생성&관리함 timestamps: true, });// 첫..

모듈 검색 순서require() : 함수 안 인자를 보고 알맞은 모듈을 로드함reuqire()에 경로 표시가 없음 → node_modules 디렉토리 내에 그런 파일이 없음 → node_modules 디렉토리 내에 그런 디렉토리가 있음 → 디렉토리 안에 package.json 파일이 있음 → main 필드에 적힌 파일 로드(main 필드가 없다면 index.js 파일 로드)package.json이라는 파일을 가진 디렉토리가 패키지다 | 하나의 서드파티모듈은 하나의 패키지다 | 서드파티모듈을 관리할 때 쓰는 npm은 node package manager의 줄임말이다package.json 파일에서 알아야할 필드name: 패키지 이름 | require 함수 인자로 넣는 것version: 패키지 버전 | nam..

서버와 클라이언트클라이언트: 서비스에 관한 요청을 서버에 보냄서버: 클라이언트 요청에 응답함웹서버 만들기http://127.0.0.1:3000127.0.0.1 → 개발용 테스트 IP | 외부 다른 컴퓨터가 아닌, 컴퓨터 자기 자신을 나타냄3000 → 코드에서 지정한 포트 번호const http = require('http'); // 통신규약// 서버 객체 생성// request: 클라이언트 요청에 관한 객체// response: 서버 객체가 할 응답에 관한 객체let server = http.createServer(function(request, response){ response.end('Hello Wolrd!');}); server.listen(3000); // 클라이언트 요청을 3000..