我是 OrientDB 的新手,之前我使用过 mongoDB。我想知道如何与 OrientDB 创建连接。
我使用了下面的代码,但不像 MongoDB 那样工作。我还想打印我的应用程序运行的端口号,例如:“监听端口 6060”
var orientdb = require('orientdb');
var dbConfig = {
user_name: "root",
user_password: "root"
};
var serverConfig = {
host: "localhost",
port: 2480 //server port Number
};
console.log(orientdb)
var server = new orientdb.Server(serverConfig);
var db = new orientdb.Db("remote:localhost/Gunjan", server, dbConfig);
//I also used 'Gunjan' only here.
db.open(function(err) {
if (err) {
throw err;
}
console.log("Successfully connected to OrientDB");
});
最佳答案
请注意,orientdb
已 fork 为 oriento
,已维护。
示例:
var Oriento = require('oriento');
var server = Oriento({
host: 'localhost',
port: 2424,
username: 'root',
password: 'yourpassword'
});
// List databases
server.list().then(function (dbs) {
console.log('There are ' + dbs.length + ' databases on the server.');
});
请注意,您必须让 OrientDB 服务器在 localhost:2424
上运行。
关于node.js - OrientDB和NodeJS如何连接DB?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28067036/