Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

What is wrong with query? I am getting syntax error, but I cannot figure out anything that's wrong

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!

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

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()
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading