javascriptmeteortelescope

How to get the _id of posts that are instantiated in posts_list?


I need to get the _id of all post_item being displayed in Telescope. It is not the posts_itens that are in the Collection but those being displayed.

Using Google Translate.


Solution

  • You can use cursor.map(), if you are trying to get an array with _id values of post_item elements:

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

    Read more about the cursor.map() method.