Some commands don't return results or only show "0"

Hi there,

Screenshot 1 shows that no results are returned when I input “db.movieDetails.find().pretty()”, while in screenshots 2 & 3 I did some queries but every result is 0 (but when I did the queries by Compass, I got the correct answers).

May I know what caused these issues and how to solve them? Thank you so much!! :slight_smile:

46%20PM

33%20PM

44%20PM

@Yuqi_Liang As a general rule, make sure you are in the database you expect. In your first screenshot, you’e loaded the movieDetails dataset in the the video database, but then you issue “use movieDetails” which is the collection name. Because of the lazy init behavior of MongoDB, it may have tried to create a movieDetails database, but since no data was put into it I >think< it won’t show up…

In your example after you load the collection, do the show collections, then do the db.movieDetails.find().pretty() w/o the intervening use movieDetails.

HTH
Mike

1 Like