How to save the whole schema while not explicitly defining some of the fields

11 views
Skip to first unread message

Michael Donux

unread,
Sep 19, 2016, 10:05:55 PM9/19/16
to Mongoose Node.JS ODM
Hi, my question is the title. And my example is as below:

var catSchema = new Schema({
    name
: String,
    color
: String,
});

var Cat = mongoose.model('Cat', catSchema);

Cat.create({ name: 'me' }, function(err, result) {
    console.log(result);
});

Is it possible to get the doc saved with both `name` field and `color` field?
Or do I have to explicitly set the `color` to `null`?

I'm hoping for all suggestions.
Reply all
Reply to author
Forward
0 new messages