nodejs orient-js不执行'then'函数

时间:2015-07-30 15:25:41

标签: node.js bluebird orientjs

我有以下代码:

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服务器不会崩溃。

1 个答案:

答案 0 :(得分:1)

Another way is to use the HTTPport parameter (in this case 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.');
});

OUTPUT:

There are 15 databases on the server.

Hope it helps