【问题标题】:How to get the _id of posts that are instantiated in posts_list?如何获取posts_list中实例化的帖子的_id?
【发布时间】:2015-07-24 14:06:27
【问题描述】:

我需要在 Telescope 中显示所有 post_item 中的 _id。集合中的不是posts_itens,而是显示的那些。

使用谷歌翻译

【问题讨论】:

  • 恐怕现在没有简单的方法可以做到这一点。也许应该有。

标签: javascript meteor telescope


【解决方案1】:

如果您尝试获取具有_id 值的数组post_item 元素,则可以使用cursor.map()

var postIdsArr = Posts.find({}, {
    _id: 1
}).map(function(post) {
    return post._id;
});

阅读更多关于cursor.map() method的信息。

【讨论】:

  • 我知道您正在使用Telescope。您能否编辑您的问题并解释您想要的结果?
猜你喜欢
  • 2015-03-14
  • 1970-01-01
  • 1970-01-01
  • 2013-04-21
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多