Mongoose 스키마 설정
2024. 1. 14. 02:40ㆍMERN
const mongoose = require("mongoose");
const Schema = mongoose.Schema;
const placeSchema = new Schema({
title: {type: String, required : true},
description: {type: String, required : true},
image : {type: String, required : true},
address: {type: String, required : true},
location : {
lat : {type: Number, required : true},
lng : {type: Number, required : true}
},
creator : {type: String, required : true},
})
module.exports = mongoose.model("Place",placeSchema)
// Model은 나중에 생성자 함수를 반환함
// 1번째 인자 - 모델의 이름
// 2번째 인자 - 모델에 참조할 스키마
'MERN' 카테고리의 다른 글
Mongoose 스키마 설정 (1) | 2024.01.14 |
---|---|
백엔드(Node) & MongoDB(데이터베이스) 연결 (3) | 2024.01.14 |
Mongoose (MongoDB - DB 생성, 조회) (0) | 2024.01.12 |
백엔드 MongoDB 데이터 베이스에 연결하기 (Mongoose 사용) (0) | 2024.01.10 |
MongoDB 연결, 시작2 (0) | 2024.01.10 |