syntaxerror:unexpected identifier at A.JS__JS

Source: Internet
Author: User
One: Problem description


Sometimes, initialize the data, the number of command bar too much, directly copy INSERT statements, paste into the command line to execute, very slow (time spent on the paste above), so the statements are placed in the JS file execution, more convenient.


However, the first time I executed the JS file today, the error:

[root@ser107 baidandan]# mongo-u root-p--authenticationdatabase admin a.js
MongoDB Shell version:2.6.9
Enter p Assword: 
connecting to:test
2015-08-04t16:35:04.913+0800 syntaxerror:unexpected identifier at A.js
Failed to load:a.js

a.js file contents:
[root@ser107 baidandan]# cat a.js use
dba;
Db.a.insert ({name: "Wang", age:20});


Two: The cause of the error


Maybe it's a bug.

The use database name cannot be used in the JS file;


III: Solutions


Remove the use database name in the JS file;

Execute again (specify the database to be manipulated in advance):


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.