Problems with find instructions

Hi I have a problem with the instruction FIND in image

In the documentation say this

Empty or Non-Existing Collections and Views

Starting in version 4.2.1 (and 4.0-series in 4.0.13), db.collection.countDocuments() returns 0 on an empty or non-existing collection or view.

In earlier versions of MongoDB, db.collection.countDocuments() errors on an empty or non-existing collection or view.


Can you elaborate about the nature of your problem.

The back image show the correct instruction executed by Mongo Compas

But when executed in Shell the results is zero

El El mié, 26 de febrero de 2020 a la(s) 20:50, steevej-1495 via MongoDB University Discussion Forum escribió:


As I can see in the first screenshot, you have switched to a non-existent database. Here are the commands that you ran :

use video

This is correct.

show collections

This is correct as well.

use movieDetails

Now, this is causing the issue. This database does not exist and that’s why your queries are returning 0.

Hope it helps!

Shubham Ranjan
Curriculum Services Engineer