InterviewSolution
Saved Bookmarks
| 1. |
Adding an index can potentially decrease the speed of which of the following operations? |
|
Answer» YES, there is very MUCH a simpler way of achieving this without having to do this programmatically. The $unwind operator deconstructs an array field resulting in a document for each ELEMENT. Consider user “John” with multiple addresses { "_id" : 1, "name" : "John", addresses: [ "Permanent Addr", "TEMPORARY Addr", "Office Addr"] } db.users.aggregate( [ { $unwind : "$addresses" } ] )would result in 3 documents, one for each of the addresses { "_id" : 1, " name " : " John ", " addresses " : "Permanent Addr" } { "_id" : 1, " name " : " John ", " addresses " : "Temporary Addr" } { "_id" : 1, " name " : " John ", " addresses " : "Office Addr" } |
|