猫鼬朋友请求模型汇总

时间:2020-11-04 13:19:39

标签: mongodb mongoose mongodb-query aggregation-framework

我正在研究一个社交媒体类型的项目,我们决定创建一个单独的模型来存储朋友的请求。它是这样的:

const Friendship = new mongoose.Schema({
  users: [{IDref for User1}, {IDref for User2}],
  accepted: []//this will store both user IDs if the friendship is reciprocal and only 1 if its not 
}) 

现在,我不知道这是否是正确的方法,但是当我想在User模型中包含用户的朋友时,这给我带来了麻烦。

根据我在文档virtual上所读的内容,不支持在数组中进行搜索,而且我不确定如何使用aggregator管道

任何帮助都将受到欢迎

0 个答案:

没有答案