谁能识别出此mongodb查询中的错误?

时间:2019-05-06 08:34:55

标签: mongodb

任何人都可以识别以下mongodb代码中的错误。我需要收集两个表在mysql中尽可能多的链接JOIN。但是我不知道该怎么做,因为我刚接触mongodb。

customers.aggregate([{"$unwind":"$orders"},{"$lookup":{"from":"orders","localField":"_id","foreignField":"cust_id","as":"orders"}},{"$unwind":"$orders"},{"$match":{"$and":[{"cancelled_time":{"$gte":"2019-04-06 06:01:12"},"created_at":{"$lte":"2019-06-06 06:01:12"}}]}},{"$group":{"_id":{"month":{"$month":"$created_at"}},"count":{"$sum":1}}}])

谢谢

我是mongodb的新手。请帮助

customers.aggregate([{"$unwind":"$orders"},{"$lookup":{"from":"orders","localField":"_id","foreignField":"cust_id","as":"orders"}},{"$unwind":"$orders"},{"$match":{"$and":[{"cancelled_time":{"$gte":"2019-04-06 06:01:12"},"created_at":{"$lte":"2019-06-06 06:01:12"}}]}},{"$group":{"_id":{"month":{"$month":"$created_at"}},"count":{"$sum":1}}}])

预期结果将列出两个集合中的对话

0 个答案:

没有答案