0

嗨,伙计们,我在连接到 orientdb 数据库时遇到了一些麻烦。

这是我的 app.js 代码

const express = require('express');
const app = express();
const path = require('path');
const router = express.Router();
const OrientJs = require('orientjs');


var server = OrientJs({
    host: "localhost",
    password: "root",
    username: "root",
    useToken: true
});

var db = server.use({
    name: 'demodb',
    username: 'admin',
    password: 'root',
    useToken: true
});

server.list()
    .then(function (dbs) {
        console.log( dbs.length + ': database/s on the server.');
    });


db.select().from('ArchaeologicalSites').all()
    .then(function (result) {
        console.log(result);
    });

app.set('view engine', 'pug')

router.get('/', function (req, res) {
    res.sendFile(path.join(__dirname + '/views/index.html'));
});

即使我尝试在 server.use() 函数中更改密码或用户名,调试器也会显示此消息。

来自调试器的消息:

Debugger listening on ws://127.0.0.1:5858/
For help, see: https://nodejs.org/en/docs/inspector
Debugger attached.
Running at Port 3000
Unhandled rejection OrientDB.RequestError: User or password not valid for username: admin, database: 'demodb'
        DB name="demodb"
    at child.Operation.parseError (C:\Users\\source\repos\ExpressApp3\ExpressApp3\node_modules\orientjs\lib\transport\binary\protocol33\operation.js:905:13)
    at child.Operation.consume (C:\Users\\source\repos\ExpressApp3\ExpressApp3\node_modules\orientjs\lib\transport\binary\protocol33\operation.js:496:35)
    at Connection.process (C:\Users\\source\repos\ExpressApp3\ExpressApp3\node_modules\orientjs\lib\transport\binary\connection.js:459:17)
    at Connection.handleSocketData (C:\Users\\source\repos\ExpressApp3\ExpressApp3\node_modules\orientjs\lib\transport\binary\connection.js:331:20)
    at Socket.emit (events.js:376:20)
    at addChunk (internal/streams/readable.js:309:12)
    at readableAddChunk (internal/streams/readable.js:284:9)
    at Socket.Readable.push (internal/streams/readable.js:223:10)
    at TCP.onStreamRead (internal/stream_base_commons.js:188:23)
    at TCP.callbackTrampoline (internal/async_hooks.js:134:14)

1: database/s on the server.

所以...它正确连接到 server.use(),实际上 server.list() 工作正常。但是当涉及到查询时,它表明 var "db" 可能有问题......

当我将 app.js 更改为此:

var db = server.use({
    name: 'demodb',
    username: 'root',
    password: 'root',
    useToken: true
});

显示的错误是这样的:

Debugger listening on ws://127.0.0.1:5858/
For help, see: https://nodejs.org/en/docs/inspector
Debugger attached.
Running at Port 3000
1: database/s on the server.
Unhandled rejection OrientDB.RequestError: Invalid authentication info for access to the database com.orientechnologies.orient.core.metadata.security.auth.OTokenAuthInfo@1798dbcf
        DB name="demodb"
    at child.Operation.parseError (C:\Users\\source\repos\ExpressApp3\ExpressApp3\node_modules\orientjs\lib\transport\binary\protocol33\operation.js:905:13)
    at child.Operation.consume (C:\Users\\source\repos\ExpressApp3\ExpressApp3\node_modules\orientjs\lib\transport\binary\protocol33\operation.js:496:35)
    at Connection.process (C:\Users\\source\repos\ExpressApp3\ExpressApp3\node_modules\orientjs\lib\transport\binary\connection.js:459:17)
    at Connection.handleSocketData (C:\Users\\source\repos\ExpressApp3\ExpressApp3\node_modules\orientjs\lib\transport\binary\connection.js:331:20)
    at Socket.emit (events.js:376:20)
    at addChunk (internal/streams/readable.js:309:12)
    at readableAddChunk (internal/streams/readable.js:284:9)
    at Socket.Readable.push (internal/streams/readable.js:223:10)
    at TCP.onStreamRead (internal/stream_base_commons.js:188:23)
    at TCP.callbackTrampoline (internal/async_hooks.js:134:14)

塞尔斯

4

0 回答 0