0

当我在僧侣中这样做时

var monk = require('monk')
var db = monk('10.25.125.20/mydb')

它工作正常,但是当我这样做时

var monk = require('monk')
var db = monk('10.25.125.20/mydb,10.25.125.22')

它会引发错误消息:“数据库名称不能包含字符'。' “ 我究竟做错了什么?

IP 地址,是我局域网中的计算机,运行 MongoDB 实例,配置为副本集,它们实际上是三个节点,但第三个是仲裁器

这就是 stderr 的内容

/home/user/Dev/project2/node_modules/monk/node_modules/mongoskin/node_modules/mongodb/lib/mongodb/db.js:233
    if(databaseName.indexOf(invalidChars[i]) != -1) throw new Error("database 
                                                          ^
Error: database names cannot contain the character '.'
    at validateDatabaseName (/home/user/Dev/project2/node_modules/monk/node_modules/mongoskin/node_modules/mongodb/lib/mongodb/db.js:233:59)
    at new Db (/home/user/Dev/project2/node_modules/monk/node_modules/mongoskin/node_modules/mongodb/lib/mongodb/db.js:95:3)
    at connectFunction (/home/user/Dev/project2/node_modules/monk/node_modules/mongoskin/node_modules/mongodb/lib/mongodb/mongo_client.js:243:29)
    at Function.MongoClient.connect (/home/user/Dev/project2/node_modules/monk/node_modules/mongoskin/node_modules/mongodb/lib/mongodb/mongo_client.js:313:5)
    at SkinClass.SkinDb._open (/home/user/Dev/project2/node_modules/monk/node_modules/mongoskin/lib/db.js:36:25)
    at SkinClass.open (/home/user/Dev/project2/node_modules/monk/node_modules/mongoskin/lib/utils.js:162:14)
    at new Manager (/home/user/Dev/project2/node_modules/monk/lib/manager.js:65:15)
    at Manager (/home/user/Dev/project2/node_modules/monk/lib/manager.js:32:12)
    at Object.<anonymous> (/home/user/Dev/project2/config/mongo.js:18:10)
    at Module._compile (module.js:456:26)
error: Forever detected script exited with code: 8
4

0 回答 0