TypeError:'undefined'在使用mongoDB排序运算符时不是函数

use*_*602 1 javascript mongodb meteor

我尝试使用最新日期获取文档,但是我收到此错误:TypeError: 'undefined' is not a function.

我的代码:

console.log(Games.find({authorId: authorId}).sort( { releaseDate: -1 } ).limit(1)); // error
console.log(Games.find({authorId: authorId}).fetch()); // expected outpout
Run Code Online (Sandbox Code Playgroud)

(该值releaseDate存在且ISODate格式正确.)任何帮助将不胜感激.

编辑:我正在使用Meteor 0.9.2.1.

use*_*602 5

得到它了!

Games.find({authorId: authorId}, { sort: { 'releaseDate' : -1 } , limit:1});
Run Code Online (Sandbox Code Playgroud)

  • 请提供一些解释,说明你之前做错了什么,以便将来的stackoverflowers可以从中学习 (2认同)