Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Web Technology by (50.2k points)

When I try to call the methods of a collection, why I am getting the error:

SyntaxError: missing; before statement @(shell)

The following is my implementation:

$ mongo

MongoDB shell version: 3.2.8

connecting to: test

Welcome to the MongoDB shell.

For interactive help, type "help".

For more comprehensive documentation, see

    http://docs.mongodb.org/

Questions? Try the support group

    http://groups.google.com/group/mongodb-user

Server has startup warnings: 

2016-08-04T11:58:21.138-0400 I CONTROL  [initandlisten] 

2016-08-04T11:58:21.138-0400 I CONTROL  [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/enabled is 'always'.

2016-08-04T11:58:21.138-0400 I CONTROL  [initandlisten] ** We suggest setting it to 'never'

2016-08-04T11:58:21.138-0400 I CONTROL  [initandlisten] 

2016-08-04T11:58:21.139-0400 I CONTROL  [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/defrag is 'always'.

2016-08-04T11:58:21.139-0400 I CONTROL  [initandlisten] ** We suggest setting it to 'never'

2016-08-04T11:58:21.139-0400 I CONTROL  [initandlisten] 

> show dbs

mydb   0.000GB

local  0.000GB

> use mydb

switched to db mydb

> show collections

201607012

> db

mydb

> mydb.201607012.find()

2016-08-04T12:10:23.826-0400 E QUERY    [thread1] SyntaxError: missing ; before statement @(shell):1:4

> db.201607012.find()

2016-08-04T12:10:29.000-0400 E QUERY    [thread1] SyntaxError: missing ; before statement @(shell):1:2

> db.201607012.find()

2016-08-04T12:11:09.115-0400 E QUERY    [thread1] SyntaxError: missing ; before statement @(shell):1:2

> db.201607012.stats()

2016-08-04T12:13:06.022-0400 E QUERY    [thread1] SyntaxError: missing ; before statement @(shell):1:2

1 Answer

0 votes
by (108k points)
edited by

In MongoDB, the name of the collection has to start with an underscore or a letter character. This is the rule for naming the collection in MongoDB. And you are naming your collection as numbers. So you have to change the name of your collection. 

Do you want to be a full-stack developer? Enroll in this Full Stack Certification to get started with your journey.

Related questions

0 votes
1 answer
asked Feb 9, 2020 in Web Technology by ashely (50.2k points)
0 votes
1 answer
0 votes
1 answer
0 votes
2 answers
0 votes
2 answers

Browse Categories

...