Given a collection posts as shown below having a document array comments, which of the following command will create an index on the comment author descending?
I'm going with B. db.posts.createIndex({\'comments.author\':1}). It's the only one that looks like it actually creates an index on the 'comments' subdocument. The others seem a bit... creative.
I think the answer is A. db.posts.createIndex({\'^comments.$.author\':-1}). It seems to create an index on the 'author' field of the 'comments' subdocument in descending order.
The correct answer is B. db.posts.createIndex({\'comments.author\':1}). The command creates an index on the 'author' field of the 'comments' subdocument in the 'posts' collection, in ascending order.
Cora
2 months agoGerardo
2 months agoLashawn
2 months agoQuentin
10 days agoNieves
11 days agoElmira
21 days agoLamar
22 days agoChandra
22 days agoGennie
1 months agoIsaiah
1 months agoRosalyn
3 months agoMonroe
3 months agoTricia
3 months agoSusana
3 months agoDelisa
3 months agoOdelia
2 months agoMaira
2 months agoBrittni
2 months agoKassandra
3 months agoMarshall
3 months agoChara
3 months ago