Closed bwgjoseph closed 3 years ago
I think this should be the correct syntax.
const { rows: populateB } = await commentModel.find({}, { populate: { post: { select: ['title', 'id'] }} });
Which gives me back
[
_Model {
id: 'b6eeee7a-0ca8-4832-a5f2-723c28047828',
post: _Model {
title: 'titleA',
id: '49ced1c7-6296-4d76-bb7e-33b2163f9819'
},
text: 'commentA'
}
]
Found on the docs-_populate which isn't very obvious/easy to find
Hello @bwgjoseph though I understand that you were not able to find it. I used https://ottomanjs.com/guides/document.html#using-population and then _populate link. I think the content is right there, may be an opportunity to re-arrange the docs might be required at some later point of time.
For now can we consider this issue to be closed ?
The question is not about how to populate
but more about populating with select
, so the link https://ottomanjs.com/guides/document.html#using-population won't work (or doesn't show it to use populate with select). You need to go https://ottomanjs.com/classes/document.html#populate which has more examples of how to get it work.
Which is why I don't see it the first time but subsequent dig into the doc got me there
Hi,
How I do use
populate with select
?This is the sample I used
So I tried the following ways to do so but I think my syntax/usage are off
It throws me this error
And this is the output with the above method call
Thanks