S
S
Shakir Darion2020-07-17 13:53:50
Mongoose
Shakir Darion, 2020-07-17 13:53:50

How to cancel populate mongoose?

this is my code

const filteringTheNecessaryFieldsForTheTour = fieldsProjection(info);
    const pathDocumentPlace = "places.place";
    const filteringTheNecessaryFieldsForThePlace = fieldsProjection(info, {
      path: pathDocumentPlace,
    });

    const tour = await tourModel
      .findById(id, filteringTheNecessaryFieldsForTheTour)
      .populate(pathDocumentPlace, filteringTheNecessaryFieldsForThePlace);


the fieldsProjection function does the filtering of the required fields from the request, it can return those fields that are needed or an empty object. an empty object means that the user doesn't need the value from "places.place", which means I don't need to call populate . Is there a way to override populate ?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question