我有兩個模式模型。const catSchema = new mongoose.Schema({ name: 'string', likes: [ { type: mongoose.Schema.Types.ObjectId, ref: 'User', require: true } ],});和const userSchema = new mongoose.Schema({ email: { type: String, required: true, unique: true, },});假設 Cat 集合中有 10 個 Cat 文檔。一位用戶喜歡兩個 Cat 文檔。我想要做的是我想通過Cat模型找到用戶喜歡的兩個貓列表。
Mongoose.js:查找所有喜歡 Cat 帖子的用戶
絕地無雙
2022-06-09 16:18:37