Does the $ slice function work in MeteorDB Meteor?

Does the function work $slice

in Meteor MongoDB?

Here's an example request:

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

      

I tried a query in mini MongoDB and posted directly using parameters, but it always returned full 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@ab.com"
    },
    ...]
    date:ISODate("2013-03-16T02:50:27.881Z")
}

      

+3


source to share


1 answer


Try the following.

Posts.find({"permalink":"udrskijwddhigfwhecxn"},{fields:{"comments":{"$slice":1β€Œβ€‹0}}})

      



Meteor projection is set by fields.

+1


source







All Articles