Upload All
This commit is contained in:
22
models/mongooseSchemas/Rating.js
Normal file
22
models/mongooseSchemas/Rating.js
Normal file
@ -0,0 +1,22 @@
|
||||
const mongoose = require("mongoose");
|
||||
const Schema = mongoose.Schema;
|
||||
|
||||
let RatingSchema = Schema({
|
||||
username : String,
|
||||
score : {type : Number, min: 1, max: 5}
|
||||
});
|
||||
|
||||
RatingSchema.statics.createNewRating = function(data, callback) {
|
||||
let newRating = this({
|
||||
username : data.username,
|
||||
score : data.score
|
||||
});
|
||||
newRating.save((err, rating) => {
|
||||
if (err)
|
||||
callback(err, null);
|
||||
else
|
||||
callback(null, rating);
|
||||
});
|
||||
}
|
||||
|
||||
module.exports = mongoose.model("Rating", RatingSchema);
|
Reference in New Issue
Block a user