0

我有以下代码:

var express = require('express');
var http = require('http');
var OrientDB = require('orientjs');
var util = require('util');
var httpApp = express();
http.createServer(httpApp).listen(8080, function() {
console.log("Server started on port 8080");

//conect to orientdb server
var server = OrientDB({
    host: 'localhost',
    port: 2480,
    username: 'root',
    password: '123456'
});

console.log('connected to orientdb.');

//list all databases
server.list()
    .then(function(dbs) {
        console.log('There are ' + dbs.length +' databases on the server.');
    }).catch(function(e) {
        console.error(e);
    });
})

控制台结果是:

Server started on port 8080
connected to orientdb.

但是当我尝试显示数据库数量时没有任何反应。为什么thencatch不被执行?我应该配置一些东西吗?!?我想提一下,nodejs服务器不会崩溃。

4

1 回答 1

1

另一种方法是使用HTTPport参数(在这种情况下2480):

var OrientDB = require('orientjs');

//server connection
var server = OrientDB({
    host: 'localhost',
    HTTPport: 2480,
    username: 'admin',
    password: 'adminPW'
});

//calculate the number of databases on the server
server.list()
    .then(function (dbs) {
    console.log('There are ' + dbs.length + ' databases on the server.');
});

输出

There are 15 databases on the server.

希望能帮助到你

于 2016-04-04T16:39:31.053 回答