我需要在同一個查詢中填充多個。
User.find({$or:[{region: "NA"},{sector:"Some Sector"}]}, function(err, user)
{
if (err)
{
res.send(err);
}
console.log(user);
res.json(user);});
uj5u.com熱心網友回復:
Post.model.js
const PostSchema = new Schema(
{
postTitle: {
type: String,
required: true,
},
users: [{ type: Schema.Types.ObjectId, ref: 'User' }],
},
{ timestamps: true },
);
像這樣查詢
const posts = await Post.find()
.populate('users', '_id firstName lastName email');
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/452695.html
標籤:猫鼬
