在遵循文件后,我无法获得$ orderby在NodeJS中工作。
这是我在NodeJS中的路线:
> db.comments.find().pretty()
{
"_id" : ObjectId("58d027f003232ca34e43d734"),
"comments" : [
{
"eventID" : ObjectId("58d2cd4e2f77b34b73dd8a04"),
"eventName" : "Yoga in the Park",
"startDateTime" : ISODate("2017-03-22T19:20:00Z"),
"comments" : [
"I really enjoyed his Yoga class.",
"He really helped me stretch out!",
"He taught me doggy style ;)"
]
},
{
"eventID" : ObjectId("58d2cd752f77b34b73dd8a05"),
"eventName" : "Spanish Lessons",
"startDateTime" : ISODate("2017-03-22T19:20:00Z"),
"comments" : [
"Learned a lot!",
"La biblioteca es manana!"
]
},
{
"eventID" : ObjectId("58d4130d5e18cdc928d0b82a"),
"eventName" : "Basketball Practice",
"startDateTime" : ISODate("2017-03-23T18:30:00Z"),
"comments" : [
"great guy! helped me improve my shooting game!",
"really knowledgeable about basketball!",
"excellent coach"
]
}
]
}
以下是我的数据库中的评论集合:
{{1}}
评论集合中的一个文档正在返回给NodeJS,但没有像我想要的那样按startDateTime排序。它按照它已经进入的顺序返回 - 这将是瑜伽,西班牙语,篮球。我也试过按1而不是-1排序,但这并没有改变结果。
谁能告诉我我做错了什么?
编辑:我正在使用和尚v1.0.1