Finding most recent entry in a meteor collection

前端 未结 2 1436
情歌与酒
情歌与酒 2021-01-13 11:19

My task sounds simple, but I can\'t nail down how to write this... I simply want to find the most recent item inserted into a collection and display it on my meteor app.

2条回答
  •  梦谈多话
    2021-01-13 11:34

    I could only get the desired result by doing

    let commentsTmp: Comment = Comments.findOne({ parentId: this.currentPost._id }, { sort: { time: -1 } });
    

    with MongoObservable.Collection

    Hope this will help someone.

提交回复
热议问题