猫鼬查询与数组参数数组

时间:2020-10-27 19:40:53

标签: node.js mongodb mongoose

我有这个帖子架构

const postSchema = new mongoose.Schema({ 
   body: string,
   authour: ref: 'User'
   topic: {ref: Topics}
})

然后我将社区模式设置为

const CommunitySchema = new mongoose.Schema({ 
   name: string,
   authour: ref: 'User'
   topics: [{ref: 'Topics'}]
})

,然后是一个用户架构

const UserSchema = new mongoose.Schema({ 
   fullname: string,
   communities: [{ref: 'Community'}]
})

如何使用数组参数数组进行查找查询。 我试过了,但是没用

Post.find({topic: user.communities.topics})

查询的外观如何?

0 个答案:

没有答案