Answer the question
In order to leave comments, you need to log in
How to validate the "Object" type in Mongoose schemas?
var mongoose = require('mongoose');
var modelSchema = new mongoose.Schema({
obj: {
type: Object,
required: true
}
});
var Model = mongoose.model('model', modelSchema);
var model = new Model({ obj: 'anything' });
model.save(function(err, doc) { console.log(err, doc); });
// -> null, { obj: 'anything' }
null
and undefined
. I understand that in JS everything except null
and undefined
is an object, but I would like some order in MongoDB collections :) Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question