【发布时间】:2021-09-09 03:08:26
【问题描述】:
我有一个朋友列表,这些朋友有一个他们自己的朋友列表,我需要为我计算最共同的朋友。我正在使用 MongoDB 作为数据库。
我的用户架构
id: {
type: String,
require: true,
unique: true
},
followers: [{
type:mongoose.Schema.ObjectId,
ref: 'User'
}],
following: [{
type:mongoose.Schema.ObjectId,
ref: 'User'
}]
})
我不确定,但是否可以在 MongoDB 中使用聚合来实现此功能。
【问题讨论】:
标签: mongodb mongodb-query nosql aggregation-framework aggregation