Heim > Fragen und Antworten > Hauptteil
有如下查询条件
let fiters = [{
route: '/',
}, {
name: 'admin1',
route: '/1',
routeGroup: '/admin'
}, {
_id: {
_str: '573aca9ce970eb6e9e543405'
}
}, {
routeGroup: '/admin'
}, {
_id: {
_str: '573c2b1e9161b32c35d76fde'
},
route: '/4'
}, {
_id: {
_str: '573ad1b5e970eb6e9e543407'
},
name: 'esdit'
}]
请问mongodb能不能一次查询上述条件数据
習慣沉默2017-05-02 09:22:23
使用$or表达式:{ $or: [ { <expression1> }, { <expression2> }, ... , { <expressionN> } ] }
db.test.find({$or:[{
route: '/',
}, {
name: 'admin1',
route: '/1',
routeGroup: '/admin'
}, {
_id: {
_str: '573aca9ce970eb6e9e543405'
}
}, {
routeGroup: '/admin'
}, {
_id: {
_str: '573c2b1e9161b32c35d76fde'
},
route: '/4'
}, {
_id: {
_str: '573ad1b5e970eb6e9e543407'
},
name: 'esdit'
}]})