node.js - Insert document with nested ObjectId -
i trying insert document mongodb looks this:
_id : objectid(<id>) players : { objectid(<id>) { entry : 'foo' } }
however, can't form json in node objectid key. what's best practice this? thanks!
according mongodb documentation:
field names strings.
so can't use objectid's keys, can use string representation:
var playersobj = {}; playersobj[objectid()] = { entry : 'foo' }; // stringify objectid var document = { _id : objectid(), players : playersobj };
Comments
Post a Comment