javascript - Array of Custom Objects MongoDB Schema -
i need create array of objects 2 fields (no methods needed) in mongodb document has field array of these objects 2 fields. have no idea schema syntax should however. how go this?
also: can declare document array , fill in javascript objects created @ run time? or should declare custom object in schema array holding document?
thanks much!
the following example creating object array of object, each 2 fields. looking for?
$ mongo mongodb shell version: 2.6.3 connecting to: test > > > db.test.insert({myarray: [{a: 1, b: 2}, {a: 3, b:4}]}) writeresult({ "ninserted" : 1 }) > db.test.findone() { "_id" : objectid("53adc9301e7d2620fc75f8c7"), "myarray" : [ { "a" : 1, "b" : 2 }, { "a" : 3, "b" : 4 } ] }
Comments
Post a Comment