Database 使用$lookup和$project与mongoDB进行Deno聚合
我正在尝试使用此库在MongoDB和Deno中使用聚合连接两个表: 根据文件,这就是我们可以使用它的方式Database 使用$lookup和$project与mongoDB进行Deno聚合,database,mongodb,lookup,deno,Database,Mongodb,Lookup,Deno,我正在尝试使用此库在MongoDB和Deno中使用聚合连接两个表: 根据文件,这就是我们可以使用它的方式 // aggregation const docs = await users.aggregate([ { $match: { username: "many" } }, { $group: { _id: "$username", total: { $sum: 1 } } }, ]); 但是,使用$lookup和$project连接两个不同
// aggregation
const docs = await users.aggregate([
{ $match: { username: "many" } },
{ $group: { _id: "$username", total: { $sum: 1 } } },
]);
但是,使用$lookup和$project连接两个不同的表没有任何功能或范围
在Deno中是否有其他方法可以同时使用查找和项目?这就是聚合在Deno和Deno_mongo中的工作方式
var data = Report.aggregate([
{
$lookup: {
from: "users",
localField: "senderId",
foreignField: "_id",
as: "sender",
},
},
{
$lookup: {
from: "users",
localField: "reportedId",
foreignField: "_id",
as: "reported",
},
},
{ $match: { status : 1 } },
{ $sort: { createdAt: 1} },
{ $skip: 10 },
{ $limit: 5 },
]).toArray();