node.js - How to add unique id to sub-document in a document in mongoose -


how add unique id sub-document in document in mongoose. mongoose model sub document not adding object id.

try "new objectid()" wherever want unique id. e.g

db.news.insert({"name":"political", "group":{"x":new objectid(),"type":"breaking"}}) 

i tried in mongodb 2.4.8 , working fine.


Comments

Popular posts from this blog

c++ - OpenCV Error: Assertion failed <scn == 3 ::scn == 4> in unknown function, -

php - render data via PDO::FETCH_FUNC vs loop -

The canvas has been tainted by cross-origin data in chrome only -