Reputation: 23
How to i populate the query result after query in mongoose like this:
users
.find({name:"doejohn"})
.skip(3)
.limit(9)
.exec((err,user) => {
user // result
.populate("tweets")
.exec(callback)
})
})
Upvotes: 0
Views: 140
Reputation: 41
It's simple:
users.findOne({username:"doejohn"})
.skip(3)
.populate("tweets"," Columns name ")
.exec((err,user) => {})
you can read the docs of populate in mongoose here:
https://mongoosejs.com/docs/populate.html
Upvotes: 1
Reputation: 26370
Simply like this :
users.findOne({username:"doejohn"})
.skip(3)
.populate("tweets")
.exec((err,user) => {})
.limit(9)
is useless, because you're using .findOne()
Upvotes: 1