【发布时间】:2019-02-28 17:32:36
【问题描述】:
我正在尝试搜索与 json 对象匹配的数据库行。
例子:
var searchParams = {
city: ['New York City', 'Budapest'],
jobs: ['Assistent'] //Can be multiple
}
//If "city" is equal to one of the searchParams.city variables
//AND jobs is equal to one of the searchParams.jobs variables
var searchQuery = {
$and: [
{$or: clean_city},
{$or: clean_cat}
]
}
Jobs.find(searchQuery, function(err, list){
console.log(list);
});
我已经尝试了所有可以在 google 上找到的选项,但似乎没有任何方法适用于数组。
如果有人能提供帮助,我将非常感激。
问候
【问题讨论】:
-
你的 db 对象是什么样的?
标签: javascript node.js mongodb mongoose mongodb-query