-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcharasSchema.js
37 lines (35 loc) · 1.27 KB
/
charasSchema.js
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 mongoose = require('mongoose');
const characterSchema = new mongoose.Schema({
frameName: { type: String, unique: true, required: true, dropDups: true },
charaName: { type: String, required: true },
costumes: [{
skinName: { type: String, unique: true, required: true, dropDups: true },
price: [{
value: { type: Number, required: [function () { return this.currency != null; }, "Insert a value"] },
currency: {
type: String,
enum: {
values: ["RC", "BC", "CB", "¥"],
message: "Pick a currency: RC, BC, CB, ¥"
},
required: [function () { return this.value != null; }, "Pick a currency: RC, BC, CB, ¥"]
},
name: { type: String, required: [function () { return this.value == null; }, "If no price is provided a message is required"] }
}],
event: [{
start: { type: Date },
finish: { type: Date },
rerun: { type: Boolean, default: false },
disc: { type: Boolean, default: false },
name: { type: String, default: "-" },
region: {
type: String, enum: {
values: ["CN", "JP", "EN"],
message: "Pick a region: CN, JP, EN"
},
required: [function () { return this.start != null; }, "If a date is provided, please provide the region too"]
}
}]
}]
});
module.exports = mongoose.model('Character', characterSchema);