我正在研究一个社交媒体类型的项目,我们决定创建一个单独的模型来存储朋友的请求。它是这样的:
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
管道
任何帮助都将受到欢迎