Why now find() of Article Model don't accept searchArr ? Pls help. very tired, do not think anything Pls help. very tired, do not think anything Pls help. very tired, do not think anything Pls help. very tired, do not think anything Pls help. very tired, do not think anything
articleSchema.statics.list = function ({tag, sort, limit, skip}) {
const Tag = mongoose.model('Tag');
const searchArr = [];
Tag.find({label: tag}, {label: false, updatedAt: false, createdAt: false, articleId: false, __v: false})
.exec()
.then( (findTags) =>{
findTags.map ((item, index) => {
searchArr.push('' + item._id);
});
console.log(searchArr);
})
.catch(e => next(e));
return this
.find({
'tags': { $in: searchArr
}
})
.sort('-' + sort)
.skip(parseInt(skip))
.limit(parseInt(limit))
.populate('tags')
.exec()
.then( (Articles) =>{
console.log('Articles');
console.log(Articles);
})
.catch(e => next(e));
};