Error: DB not defined

Wondering if someone could highlight what I’m doing wrong here, seems to switch to the DB ok but then proceeds to state that it is ‘Not Defined’.

mongo

Hello @Kyle_24875,

Issue show collections

If there is none, then one possibility is that you didn’t load the sample dataset?

This is done in Atlas.

2 Likes

The general syntax for working with collections is:

db.CollectionName.method()

in your case it would be

db.sample_training.find( ... )

So you forgot the leading db.

2 Likes

Hi @Kyle_24875,

Use db object rather than the name of your database in your queries.

When you run the use database_name command, the db object automatically starts pointing to the mentioned database.

1 Like

Thank you all for the extremely helpful advice!