2
我有一个基于以下架构(简体)型号:Mongoose - 查找其数组属性包含给定子集的所有文档?
schema = mongoose.Schema({
foo: { type: String },
bars: [{ type: String }]
});
model = mongoose.model ('model', schema);
,我想创建一个API可以返回包含所有这些都在一个逗号分隔的列表中提供的“酒吧”的所有文档。所以,我有:
exports.findByBars = function (req, res) {
var barsToFind = req.body.bars.split(',');
// find the matching document
};
猫鼬是否为此提供了一个API还是有一个查询参数,我可以传给型号找得到这个功能呢?如果它的bar属性包含barsToFind
数组中的所有值,我只希望返回一个文档。