OrientDB和NodeJS如何连接数据库?

在OrientDB中,我是新的,我使用了mongoDB。 我想知道如何创build与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服务器。