node.js - OrientDB和NodeJS如何连接DB?

标签 node.js orientdb

我是 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/

相关文章:

node.js - 使用 CryptoJS 解密 openssl AES

java - 尝试与 OrientDB 合作

sql - 新手: OrientDB Basic SQL Query

javascript - Algolia 重复

node.js - 发送 Content-Type : application/json post with node. js

node.js - 如果更改某个属性,请勿更改 Updated_at 属性

javascript - Node js递归文件夹包含

etl - Orientdb 和传送器问题

orientdb - 与 OrientGraph 的嵌套事务

java - 为什么会出现 Invalid keywords : PROPERTY error in orientdb?