Showing
1 changed file
with
0 additions
and
35 deletions
models/ProductsModel.js
deleted
100644 → 0
1 | -var mongoose = require('mongoose'); | ||
2 | -var Schema = mongoose.Schema; | ||
3 | - | ||
4 | -//생성될 필드명을 정한다. | ||
5 | -var ProductsSchema = new Schema({ | ||
6 | - name: { | ||
7 | - //제품명 | ||
8 | - type: String, | ||
9 | - required: [true, '제목은 입력해주세요'], | ||
10 | - }, | ||
11 | - thumbnail: String, //이미지 파일명 | ||
12 | - price: Number, //가격 | ||
13 | - description: String, //설명 | ||
14 | - created_at: { | ||
15 | - //작성일 | ||
16 | - type: Date, | ||
17 | - default: Date.now(), | ||
18 | - }, | ||
19 | - username: String, //작성자추가 | ||
20 | -}); | ||
21 | - | ||
22 | -ProductsSchema.virtual('getDate').get(function () { | ||
23 | - var date = new Date(this.created_at); | ||
24 | - return { | ||
25 | - year: date.getFullYear(), | ||
26 | - month: date.getMonth() + 1, | ||
27 | - day: date.getDate(), | ||
28 | - }; | ||
29 | -}); | ||
30 | - | ||
31 | -// 1씩 증가하는 primary Key를 만든다 | ||
32 | -// model : 생성할 document 이름 | ||
33 | -// field : primary key , startAt : 1부터 시작 | ||
34 | - | ||
35 | -module.exports = mongoose.model('products', ProductsSchema); | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
-
Please register or login to post a comment