[ key : { value1 : '123', value2 : '123' } ] instead
[ { value1 : '123', value2 : '123' } ] [ key : { value1 : '123', value2 : '123' } ] instead
[ { value1 : '123', value2 : '123' } ] You get an invalid json:
[ key : { value1 : '123', value2 : '123' } ] I suppose you need to get all the same array:
[ { "key" : { "value1" : "123", "value2" : "123" } } ] Then you can use the map :
db.test.insert({value1: '123', value2: '123'}) db.test.find().map(function(e) {return {key: e};} Source: https://ru.stackoverflow.com/questions/533829/
All Articles