I have a model that i want to get the user aggregate after some lookup during the login which I am thinking of adding to the mongoose hook below
schema.pre("find", async function (next) {
this.aggregate([
{$lookup: {from: "categories", localField: "categories", foreignField: "_id", as: "categories"}},
])
next();
});
But this
does not have the aggregate method exposed at this point. What is the possible solution I can opt-in for ? I don't want to make a separate aggregate call or a different endpoint for just the aggregate