I\'m new to mongodb and node.js. Let me know, how do I set default value after creating the user.
Here is my current code:
// CREATE USER
app.post(\"
As you're using Mongoose, you can set the default as part of the Schema
definition:
var userSchema = new Schema({
win: { type: Number, default: 0 }
});
The options are documented here. It's also cool that if you set the default to a function, it will execute when the Model is instantiated. For example, if it were: default: Date.now
, it will call the Date.now()
function when a model is created.