S
S
Stanislav2017-11-11 11:32:36
MongoDB
Stanislav, 2017-11-11 11:32:36

How to make a selection with populate?

I don’t understand how to make a selection by the fields that populate fills
The selection itself

Posts
        .find({
             public: true
        }, {
            id: 1,
            url: 1
        })
        .sort({ createdAt: -1 })
        .skip(d.query.skip)
        .limit(d.query.limit)
        .populate('likes', 'id')
        .populate('owner', 'id name username avatar')
        .populate('catalog', 'id url name', {'url': 'CATALOG_NAME'})
        .exec((e, data) => {

            return c(e, data)
    });

As a result, I get all records where the catalog (CATALOG_NAME) matches, the catalog field is filled, and where it is not displayed simply null
I need to select records only with a certain category, where the catalog URL matches the passed key.
How can this be done?

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