Sunday, 11 June 2017

When Use Reference In mongoose Cant Save Null Or Empty

I have a simple model like this:

const model = {
 image: {
    smallImage: {type: Schema.ObjectId, ref: 'Images', default: null,required: true},
    hoverImage: {type: Schema.ObjectId, ref: 'Images'}
 }
};

as you can see, hoverImage is optional, but when i want save null in hoverImage I get the an Error.



via Alireza Valizade

No comments:

Post a Comment