-
Notifications
You must be signed in to change notification settings - Fork 2
Model
Amir Hossein Seyhani edited this page Jul 21, 2017
·
2 revisions
In this section we do some work with mongoose. its an ODM for mongoDB.
var mongoose = require("mongoose");
var ScoreSchema = new mongoose.Schema({
username:String,
score:Number
});
To define a table in mongo we define a shcema. then we define a model in order to be able to work with this document collections (e.g. we had findOne function on score model).
var scoreModel = mongoose.model("Score", ScoreSchema);
module.exports = scoreModel;
And then put this file socre.js in models directory