Sunday 15 July 2012

node.js - Stop Mongoose from creating _id property for sub-document array items -


If you have subdownment arrays, then Mongo automatically creates an id for every one Example: < "Value"), {_id: "unwanted id", field: "value"}]}} {_id: "mainId" subdocArray: [{_id: "unwanted id", field: / Pre>

Is there a way to make the merge not an ID for the objects within an array?

It's easy, you can define it in subschema:

 < Code> var mongoose = require ("mongoose"); Var subscema = Mongoose Sema ({// your subschema content}, {_id: false}); Var schema = mongos Shma ({// schema content sub-sachema collection: [subscema]}); Var model = mongos Model ('tablaanem', schema);    

No comments:

Post a Comment