Open
Description
I have a model "accounts" with a users array, userId in users items referred to the users model.
but when I want to get a list of accounts or findOne, I can't get the user document by populate
const schema = new Schema(
{
...
owner: { type: Schema.Types.Reference, ref: "users" }, // Reference to Users (works),
users: [
{
userId: { type: Schema.Types.Reference, ref: "users" }, // Reference to Users (not works)
...
}
this my find service:
accountsModel.find(filters, {
populate: {
owner: ["firstName", "lastName", "email", "type", "id"],
users :{
populate: {
userId: ["status", "id", "firstName", "lastName", "email", "type"],
}
},
populateMaxDeep: 3,
});
Metadata
Metadata
Assignees
Labels
No labels