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
1 months agoGerardo
1 months agoLashawn
1 months agoGennie
14 days agoIsaiah
14 days agoRosalyn
2 months agoMonroe
2 months agoTricia
2 months agoSusana
2 months agoDelisa
2 months agoOdelia
17 days agoMaira
18 days agoBrittni
24 days agoKassandra
2 months agoMarshall
2 months agoChara
2 months ago