$expr query is not working in IDE and it works in Atlas collection

For lab $expr question: How many companies in the sample_training.companies collection have the same permalink as their twitter_username?

When i enter a query in IDE :

db.companies.find (
    $expr:  { $eq: ["$permalink", "$twitter_username"] }

It shows the result as 0.

When i enter the same query in Atlas collections filter :


It shows many results.

can someone help me with this issue I don't understand why am i getting this issue.

Most likely you are not using sample_training database.

Show the output of the 2 commands below from inside the IDE.

1 Like

MongoDB Enterprise atlas-8z9ka2-shard-0:PRIMARY> db.companies.find().count()
MongoDB Enterprise atlas-8z9ka2-shard-0:PRIMARY> db
MongoDB Enterprise atlas-8z9ka2-shard-0:PRIMARY>

Then, have you tried your query?

It works. As said below, make sure, you use the right collections.

can you tell me the answer plz?, in mine it’s showing 0 as the output

1 Like