how to use aggregate function in meteor

前端 未结 4 1265
悲哀的现实
悲哀的现实 2020-12-07 01:46

I\'m working on the following document

{
\"_id\" : 12,
\"firstName\" : \"wer\",
\"People\" : [ 
    {
        \"uuid\" : \"123\",
        \"name\" : \"sugun\         


        
4条回答
  •  温柔的废话
    2020-12-07 01:54

    Here is what I tried manually and worked for me:

    var rawUsers = Meteor.users.rawCollection();
    var aggregateQuery = Meteor.wrapAsync(rawUsers.aggregate, rawUsers);
    var pipeline = [
        {$match: {}},
        {$project: {username: 1, profile: 1}}
    ];
    var result = aggregateQuery(pipeline);
    
    return result;
    

    Read more about Meteor.wrapAsync here

提交回复
热议问题