OrientDB和NodeJS如何连接DB?

OrientDB and NodeJS How to connect DB?

我是 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 已分叉为 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.');
});

请注意,您必须在 localhost:2424 上安装 OrientDB 服务器 运行。