Meteor客户端排序集合 [英] Meteor client side sort Collection
问题描述
我有一个DrawingHistory集合,它存储用于重绘canvas数据的数据,但我似乎找不到一种方法来按时间属性排序信息。这是我当前的函数
I have a DrawingHistory collection which stores data to be used for redrawing canvas data, but I can't seem to find a way to sort the information by a time property. Here's my current function
DrawingHistory.find().observeChanges
added: ( id , data ) =>
@setupUserDraw data unless Session.equals 'user_id' , data.sid
我看着网上排序,人们说, DrawingHistory.find()。sort({time:-1})
但find()不有排序属性。
Sometimes the order gets messed up, and I looked online for sorting where people say to do DrawingHistory.find().sort( { time: -1 } )
but find() doesn't have a sort property. Any ideas where I'm off?
推荐答案
如果我的记忆没有让我失望,这应该做,第一个 {}
是选择器,第二个 {...}
是选项。
If my memory isn't failing me, this should do it, the first {}
being the selector, the second {...}
being the options.
DrawingHistory.find({}, {sort: {time: -1}});
编辑:找到 docs on find()。
这篇关于Meteor客户端排序集合的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!