These are chat archives for Automattic/mongoose

25th
Aug 2017
Artyom Tsurkan
@artsurkan
Aug 25 2017 21:42
How to find all articles by a certain Tag,label, if in Articles instances I have only array of _id 's of Tag model and all label in Tag model?
articleSchema.statics.list = function ({tag, sort, limit, skip}) {

    return this
        .find({
            ??????????????? 'tags': tag  ???????????
        })
        .sort('-' + sort)
        .skip(parseInt(skip))
        .limit(parseInt(limit))
        .populate('tags')
        .exec()
        .then( (savedArticle) =>{
            console.log(savedArticle);

        })
        .catch(e => next(e));
};