mongo shell script won't let me include “use

前端 未结 3 1580
失恋的感觉
失恋的感觉 2020-12-25 12:26

32-bit mongo 2.0.1 on a windows XP machine

//script filename: test.js  (one line shell script file to store a person)
db.cTest.save({Name: \"Fred\", Age:21})         


        
3条回答
  •  粉色の甜心
    2020-12-25 12:43

    http://www.mongodb.org/display/DOCS/Scripting+the+shell

    use dbname
    This command does not work in scripted mode. Instead you will need to explicitly define the database in the connection (/dbname in the example above).

    Alternately, you can also create a connection within the script:

    db2 = connect("server:27017/otherdbname")

提交回复
热议问题