MongoDB aggregation on Loopback

前端 未结 2 1788
臣服心动
臣服心动 2020-12-16 06:04

How do I obtain the sum of a Loopback PersistedModel?

There does not seem to be a documentation on how to achieve that.

If possible I would like to avoid ha

2条回答
  •  执笔经年
    2020-12-16 06:48

    Aggregate query with loopback

    Products.getDataSource().connector.connect(function(err, db) {
         var collection = db.collection('Products');
            collection.aggregate(
           [{ $match: { "productCode" : "WIN10-NoOS" } }]
            ).toArray(function(err,servicesData){
                  if(err){
    
                   }else{
                 cb(null,servicesData);
               }
    
             });
        });
    

提交回复
热议问题