Do you want to request a feature or report a bug?
Feature
What is the current behavior?
If you want to populate a virtual field which also has a getter function you can't set localField to the virtual property itself and call populate() for the virtual with the option to apply getters first.
What I am trying to do is attaching a virtual property owner to the document which yields the uid of the array element from users with role: 0. I then want to populate the owner field with the actual document of the owner.
This could be the virtual property:
WhiteboardSchema.virtual("owner", {
ref: "User",
localField: "owner",
foreignField: "uid",
justOne: true
}).get(() => {
return // the uid of the element with role: 0 from users array
});
It would be nice if you could fill a virtual property with a value calculated from other fields (using the virtuals getter function) and then call populate on the same virtual to fill it with a doc from another collection.
Or is there any other clever solution to my problem?
Do you want to request a feature or report a bug? Feature
What is the current behavior? If you want to populate a virtual field which also has a getter function you can't set
localField
to the virtual property itself and call populate() for the virtual with the option to apply getters first.Got this schema:
What I am trying to do is attaching a virtual property
owner
to the document which yields theuid
of the array element fromusers
withrole: 0
. I then want to populate theowner
field with the actual document of the owner. This could be the virtual property:It would be nice if you could fill a virtual property with a value calculated from other fields (using the virtuals getter function) and then call populate on the same virtual to fill it with a doc from another collection.
Or is there any other clever solution to my problem?