Showing
2 changed files
with
9 additions
and
3 deletions
... | @@ -4,10 +4,16 @@ const Schema = mongoose.Schema; | ... | @@ -4,10 +4,16 @@ const Schema = mongoose.Schema; |
4 | 4 | ||
5 | const BottleSchema = new Schema ({ | 5 | const BottleSchema = new Schema ({ |
6 | bottleId : { type : String, required : true, unique : true }, | 6 | bottleId : { type : String, required : true, unique : true }, |
7 | - balance : Number, | 7 | + temperature : { type : Number, default : 0 }, |
8 | - recentOpen : Date, | 8 | + humidity : { type : Number, default : 0 }, |
9 | + balance : { type : Number, default : 0 }, | ||
10 | + recentOpen : { type : Date, default : Date.now }, | ||
9 | medicineId : Number, | 11 | medicineId : Number, |
10 | hubId : Number | 12 | hubId : Number |
11 | }) | 13 | }) |
12 | 14 | ||
15 | +BottleSchema.statics.findByBottleId = function(bottleId) { | ||
16 | + return this.findOne({ bottleId }); | ||
17 | +}; | ||
18 | + | ||
13 | module.exports = mongoose.model('Bottle', BottleSchema); | 19 | module.exports = mongoose.model('Bottle', BottleSchema); |
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
... | @@ -9,7 +9,7 @@ const MedicineSchema = new Schema ({ | ... | @@ -9,7 +9,7 @@ const MedicineSchema = new Schema ({ |
9 | target : { type : String, required : true }, | 9 | target : { type : String, required : true }, |
10 | dosage : { type : String, required : true }, | 10 | dosage : { type : String, required : true }, |
11 | warn : { type : String, required : true }, | 11 | warn : { type : String, required : true }, |
12 | - antiEffect : String | 12 | + antiEffect : { type : String, required : true } |
13 | }) | 13 | }) |
14 | 14 | ||
15 | MedicineSchema.statics.findByName = async function(name) { | 15 | MedicineSchema.statics.findByName = async function(name) { | ... | ... |
-
Please register or login to post a comment