M201 Lab 1.1 - What am I doing wrong

I’ve tried the answer “20” and the answer “0”.

Click the screenshot above to see that I successfully imported the people.json file into a db called m201. I’ve also checked that I can successfully query the people collection(see screenshot). The answer I get is “0”.

Though I have opened this collection up on mongodb compass and see there are 20 emails.

Please help, I only have one more attempt at this answer.

Remember to:
use m201


Hello @007_jb

Thank you for your response.

I think I am using m201 --> https://www.screencast.com/t/LfpbU49nwL

@Nicholas_90117 that’s unfortunately not the correct syntax. You’re getting 0 records because it’s using the default database test.

In MongoDB you need to switch to the database before you can access its collections:

# Switch to the m201 db
use m201

# Run your query on the people collection

@007_jb Well don’t I feel sheepish.

Thank you so much for #1 trying to help me get the answer on my own, and #2 handing it to me on a silver platter.

Lab 1.1 is completed correctly.

1 Like

You’re welcome!

Yay! 5 more labs to go :grinning:

mongoimport --db=m201 --collection=people --file E:\MongoDB\mongofile\people.json
2019-11-11T17:05:23.046-0600 E QUERY [js] uncaught exception: SyntaxError: unexpected token: identifier :

Getting above error

Got resolved, I was executing wrong.

1 Like

In the future, it’s best to create your own thread. :+1: