Mongo流星聚合返回BSON类型

问题描述 投票:0回答:1

我有以下汇总查询

var pipeline=[ { $match: { Active:1, Duration:'monthly' } },{ $sample: { size: 3 } }]
Products.aggregate(pipeline).toArray((err, result) => {
  subscription.added('random-aggregate', 'random-order', { result: result });
});

它返回正确的结果,但是ObjectId为BSON类型,这使得难以对其进行进一步处理。如何获取收集记录的正确对象ID?随附屏幕截图,该ID在控制台enter image description here]上的外观>

尽管检查MiniMongo Meteor屏幕时ID看起来很正常,而且在项目中我使用的其他查询中ID的格式也正确enter image description here

我有以下聚合查询varpipeline = [{$ match:{Active:1,Duration:'monthly'}},{$ sample:{size:3}}] Products.aggregate(pipeline).toArray(( err,result)=> {subscription.added('...

mongodb meteor mongodb-query bson
1个回答
0
投票

我确定您现在必须已经解决了这个问题,以防万一其他人遇到这个问题...

© www.soinside.com 2019 - 2024. All rights reserved.