Query Operators

I have tried running the queries in the inbuilt IDE but it’s failing every time.

I ran this command db.zips.find( {"pop": {"$lt": 1000}} ).count() but it returned the whole collection.
But when I try running another query on a different collection. It works.

Thank you

1 Like

Use straight quotes on pop field like the ones you used on $lt

2 Likes

That’s the terminal snippet. I think maybe the Sample data is corrupted. Will try and load it again and then run the query command again.

Thanks

1 Like

Hi @Asiimwe_Edgar,

Your query is correct. Kindly reload the sample data and try again.

In case you have any doubts, please feel free to reach out to us.

Thanks,
Kushagra Kesav,
Curriculum Services Engineer

3 Likes

Before you do the following:

Make sure you are using the appropriate database. Please share the output of the mongo shell command:

db

Hi Kushagra – How do I reload the sample data?

Thanks

You can reload data from Atlas
You have to drop all sample DBs and reload data or drop your cluster and create new one and load the sample data

With reference to your other thread i don’t think it is needed as you were running queries against wrong DB

Hey @John_Turnbull,

Kindly follow the given steps in the shared thread:

Thanks,
Kushagra

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