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
13 days agoGerardo
14 days agoLashawn
17 days agoRosalyn
2 months agoMonroe
28 days agoTricia
1 months agoSusana
2 months agoDelisa
2 months agoMaira
20 hours agoBrittni
7 days agoKassandra
30 days agoMarshall
2 months agoChara
2 months ago