Hy guys, I'm facing some trouble in connecting to an orientdb database.
Here is my app.js code
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'));
});
The debugger shows this message even if I try to change the password or the username in the server.use() function.
the message from the debugger:
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.
So...it correctly connects with server.use(), in fact server.list() works fine. But when itcomes to the query it shows that maybe the var "db" has something wrong...
When i change the app.js to this:
var db = server.use({
name: 'demodb',
username: 'root',
password: 'root',
useToken: true
});
the error shown is this:
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)
Ceers