I'm very new to Node js and Mongoose module. I'm trying to create a schema, where there are some required fields and some others can be dynamic.
I have used strict to false. My code looks like this:
var mongoose = require('mongoose')
var db = mongoose.connect('mongodb://localhost/ets',function(err)
{
if(err) throw err
})
var Schema = mongoose.Schema
var Tasks = new Schema({vmProfile:String}, { strict: false });
mongoose.model('Task',Tasks)
var Task = mongoose.model('Task')
var task = new Task()
task.vmProfile = "required value"
task.otherKey = "something"
task.save(function(err)
{
if(err) throw err;
})
when I run this , I get only the vmProfile saved, not otherKey, the DB looks like this:
{ "vmProfile" : "required value", "_id" : ObjectId("53364a5a5cd71a76122f0a8a"), "__v" : 0 }
where I'm making the mistake.