mongoose create populate response
let user = await User.create({ ... })
user = await user.populate('company').execPopulate()
mongoose create populate response
let user = await User.create({ ... })
user = await user.populate('company').execPopulate()
populate example in mongoose
const Live = new Schema(
{
user_id:{ // this one populate
type: Schema.Types.ObjectId,
ref: 'User', // User Schema
required: true
},
title: {
type: String,
},
category:{ // this one populate
type: Schema.Types.ObjectId,
ref: 'Category' // Category Schema
},
}
)
let vid = await Live.find({})
.populate({path:'user_id',select:'name image -_id'})
.populate({path:'category',select:'category -_id',model:Category})
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us