1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
| const exampleSchema = mongoose.Schema({
firstName: {
type: String,
required: true,
trim: true,
lowercase: true
},
lastName:{
type: String,
trim: true,
lowercase: true
}
age:{
type: Number,
required: true,
}
created:{
type: Date,
default: Date.now
},
number:{
type: Number,
match: /^\d{3}-\d{3,4}-\d{4}$/
},
password:{
type: String,
validate: [
function(password) {
return password && password.length>6;
}, '비밀번호를 입력하거나 길이가 6보다 커야합니다.'
]
},
author:{
type: Schema.Types.Id,
ref: 'User'
}
});
|