Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does the $slice function in MongoDB Meteor work?

Tags:

mongodb

meteor

Does the $slice function work in Meteor MongoDB?

Here is some query sample:

 Posts.find({"permalink":"udrskijwddhigfwhecxn"},{"comments":{"$slice":10}});

I tried querying in the mini MongoDB and directly through publish using parameters, but it always return the complete nested data.

{
    _id:Object(1231o2j3lkqj),
    body:"this is body",
    author:"machine",
    permalink:"udrskijwddhigfwhecxn"
    title:"this is title",
    tags: ["dog","cat","tree"]
    comments: [{
       body:"comment body",
       author:"lara",
       email:"[email protected]"
    },
    ...]
    date:ISODate("2013-03-16T02:50:27.881Z")
}
like image 398
Julius Limson Avatar asked Mar 01 '26 11:03

Julius Limson


1 Answers

you can split the following. by using The projection in Meteor and it is specified by fields.

Posts.find({"permalink":"udrskijwddhigfwhecxn"},
{
fields:{"comments":{"$slice":1‌​0}}
})
like image 130
Julius Limson Avatar answered Mar 05 '26 03:03

Julius Limson