MongoDB Insert Document Practice Lab

I am using the mongoDb Insert Practice lab, however I get the error as below

root@mongodb:/app# db.accounts.insertOne(
bash: syntax error near unexpected token `newline’
root@mongodb:/app# {

account_id: 111333,
limit: 12000,
products: [
  "Commodity",
  "Brokerage"
  ],
"last_updated": new Date()

bash: syntax error near unexpected token (' root@mongodb:/app# } bash: syntax error near unexpected token }’
root@mongodb:/app# db.accounts.insertOne({
bash: syntax error near unexpected token {' root@mongodb:/app# account_id: 111333, bash: account_id:: command not found root@mongodb:/app# limit: 12000, bash: limit:: command not found root@mongodb:/app# products: [ bash: products:: command not found root@mongodb:/app# "Commodity", bash: Commodity,: command not found root@mongodb:/app# "Brokerage" bash: Brokerage: command not found root@mongodb:/app# ], bash: ],: command not found root@mongodb:/app# "last_updated": newDate() bash: syntax error near unexpected token (’
root@mongodb:/app# })
bash: syntax error near unexpected token }' root@mongodb:/app# db.accounts.insertOne({account_id:111333,limit:12000,products:["Commodity","Brokerage"],"last_updated":newDate()}) bash: syntax error near unexpected token {account_id:111333,limit:12000,products:[“Commodity”,“Brokerage”],“last_updated”:newDate’

2 Likes

Same error here, I think they have are a problem setting up the environment, because really we are not inside a mongo shell. If we run “run.sh” file, we see this error:

File details and existing Atlas cluster match, using stored file details to connect to Atlas.
mongosh mongodb+srv://catalina-student-crud1-lesson1:********@instruqttest.3xfvk./sample_analytics
Error: querySrv ENOTFOUND _mongodb._tcp.instruqttest.3xfvk.
./run.sh: line 34: [: -gt: unary operator expected
Re-running the ./run.sh as a network error occurred.
1 Like

I also encountered the same error. How do I resolve it and move to the next exercise or lesson?

Hi, I have the same issue. I tried to resolve it by running shell connection string in command line. Also I needed to activate “ALLOW ACCESS FROM ANYWHERE” beforehand.

When connected I switched to db sample_analytics:
> use sample_analytics
After I ran the insert command.
The document was inserted and I can find it in DB (Atlas UI) but when I click “Check” I get:
“Incorrect solution
The document were not found in the database. Please try again”.

I hope it will be fixed soon.

1 Like

In my case, I don’t have any errors, but I can’t see my data. If I run db.accounts.find() it lists all data without the new one. It looks like my data is not being inserted.

Same here, tried connecting via connection string & added the doc that way, however it still says “The document were not found in the database. Please try again” even though I can see the doc in the Atlas UI & Compass

1 Like

Same issue here with mongodb-indexes lesson 2 lab. Seems like an issue accross all labs?

I encountered the same issue, so I tried using a MongoDB shell connection string and attempted to insert a document; however, I still received an error stating ‘document not found in the database.’

Yes I encountered the same error:

image

It worked fine today; the check passed

Hi All,

Can you please check again if you are still getting the same issue?

In case you are not getting connected automatically to the Atlas cluster after launching a lab, I would recommend you to send an email to learn@mongodb.com with details such as:

  • Course name and lab you are facing issue with.
  • What is the exact issue that you are getting?

Happy Learning, cheers!
Tarun