db.haidb.find({
"Provider ID": {
"$exists": true
},
"Address": {
"$exists": true
},
"City": {
"$exists": true
},
"Measure ID": {
"$regex": /^HAI_1.*SIR$/
},
{
"$or": ["State": {
"$regex": /^A/i
}, "State": {
"$regex": /^N/i
}]
},
{
"$and": [{
"Compared to National": "Better than the National Benchmark"
}, {
"Score": {
"$gte": 0.5
}
}]
}
}).sort({
"Hospital Name": 1.0
}).pretty()
This is what Mongo throws: SyntaxError: Unexpected token (1:153)
Please help!
CodePudding user response:
The $or
and $and
sections were not placed correctly.
This shall work.
db.haidb.find({
"Provider ID": {"$exists": true},
"Address": {"$exists": true},
"City": {"$exists": true},
"Measure ID": {"$regex": /^HAI_1.*SIR$/},
"$or": [
{"State": {"$regex": /^A/i}},
{"State": {"$regex": /^N/i}}
],
"Compared to National": "Better than the National Benchmark",
"Score": {"$gte": 0.5}
}).sort({
"Hospital Name": 1.0
}).pretty()