windows XP机器上的32位mongo 2.0.1
//script filename: test.js (one line shell script file to store a person)
db.cTest.save({Name: "Fred", Age:21});
通过输入以下两个shell命令来运行数据库dbTest:
> use dbTest
switched to dbTest
> load("test.js")
到目前为止,一切顺利.
但如果我try 在脚本中包含"use"语句,它就会失败:
//script filename: test.js (including "use" statement)
use dbTest;
db.cTest.save({Name: "Fred", Age:21});
失败,错误消息如下:
> load("test.js")
SyntaxError: missing ; before statement
Mon Dec 19 11:56:31: Error: error loading js file temp.js (shell):1
添加或删除要测试的分号.js似乎并不重要.
那么,如何将"use"指令放入mongo shell脚本中呢?