이승윤

fix: ProductsModel 삭제

var mongoose = require('mongoose');
var Schema = mongoose.Schema;
//생성될 필드명을 정한다.
var ProductsSchema = new Schema({
name: {
//제품명
type: String,
required: [true, '제목은 입력해주세요'],
},
thumbnail: String, //이미지 파일명
price: Number, //가격
description: String, //설명
created_at: {
//작성일
type: Date,
default: Date.now(),
},
username: String, //작성자추가
});
ProductsSchema.virtual('getDate').get(function () {
var date = new Date(this.created_at);
return {
year: date.getFullYear(),
month: date.getMonth() + 1,
day: date.getDate(),
};
});
// 1씩 증가하는 primary Key를 만든다
// model : 생성할 document 이름
// field : primary key , startAt : 1부터 시작
module.exports = mongoose.model('products', ProductsSchema);
\ No newline at end of file