mongoose create nested object code example
Example 1: mongoose select nested
var fields = { 'properties.OBJECTID': 1, 'properties.TIMESTAMP': 1 };
var query = Feature.find({id: 1}).select(fields);
Example 2: mongoose nested require
var jobSchema = Schema({
negotiation: { state: { type: String, required: hasNegotiation } }
});
function hasNegotiation() {
return this.negotiation && Object.keys(this.negotiation).length > 0;
}