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

17 views
Skip to first unread message

Michael Donux

unread,
Sep 19, 2016, 6:18:41 AM9/19/16
to mongoose-users
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.

Sergey Lyubka

unread,
Sep 19, 2016, 11:46:35 AM9/19/16
to mongoose-users
Wrong mailing list.
This list is dedicated to https://github.com/cesanta/mongoose

--
You received this message because you are subscribed to the Google Groups "mongoose-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mongoose-users+unsubscribe@googlegroups.com.
To post to this group, send email to mongoose-users@googlegroups.com.
Visit this group at https://groups.google.com/group/mongoose-users.
For more options, visit https://groups.google.com/d/optout.

Michael Donux

unread,
Sep 19, 2016, 10:04:36 PM9/19/16
to mongoose-users
Sorry for that, I'll delete the post.


On Monday, September 19, 2016 at 11:46:35 PM UTC+8, Sergey Lyubka wrote:
Wrong mailing list.
This list is dedicated to https://github.com/cesanta/mongoose
On Mon, Sep 19, 2016 at 11:18 AM, Michael Donux <michae...@gmail.com> wrote:
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.

--
You received this message because you are subscribed to the Google Groups "mongoose-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mongoose-user...@googlegroups.com.
To post to this group, send email to mongoos...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages