Syntax Error: Unexpected token, expected "," (1:22)

Hi guys,

I’m pretty new to MongoDB and just starting my journey learning different ways I can query my documents. I am trying to lean the $and operator but for some reason keep getting the same error. I’m using the sample_training database from MongoDB and my query is

db.companies.find($and: [{company_code:‘social’}, {founded_month:2004}])

What am I doing wrong?

learn* sorry for the typo


You should wrap whole query with {}. Try this:

db.companies.find({$and: [{company_code:'social'}, {founded_month:2004}]})

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.