0

NodeJS サーバーでorientjsドライバーを使用しています。最初のデータベース接続後にサーバー インスタンスが変更されるという問題があります。最初に、私のサーバーは次のようになります。

Server {
  useToken: false,
  logger: 
   { error: [Function: bound bound ],
     log: [Function: bound bound ],
     debug: [Function] },
  transport: 
   BinaryTransport {
     domain: null,
     _events: { reset: [Function: bound ] },
     _eventsCount: 1,
     _maxListeners: Infinity,
     connecting: false,
     closing: false,
     retries: 0,
     maxRetries: 5,
     host: 'localhost',
     port: 2424,
     username: 'root',
     password: 'Orientdb',
     servers: [ [Object] ],
     currentServer: 0,
     enableRIDBags: true,
     useToken: false,
     token: null,
     sessionId: -1,
     logger: 
      { error: [Function: bound bound ],
        log: [Function: bound bound ],
        debug: [Function] },
     connection: 
      Connection {
        domain: null,
        _events: [Object],
        _eventsCount: 3,
        _maxListeners: Infinity,
        host: 'localhost',
        port: 2424,
        socket: null,
        logger: [Object],
        enableRIDBags: true,
        closing: false,
        reconnectNow: false,
        protocol: null,
        queue: [],
        writes: [],
        remaining: null } },
  config: 
   { get: [Function: bound ],
     set: [Function: bound ],
     list: [Function: bound ] },
  domain: null,
  _events: {},
  _eventsCount: 0,
  _maxListeners: Infinity }

データベースに接続すると、次のようになります。

Server {
  useToken: false,
  logger: 
   { error: [Function: bound bound ],
     log: [Function: bound bound ],
     debug: [Function] },
  transport: 
   BinaryTransport {
     domain: null,
     _events: { reset: [Function: bound ] },
     _eventsCount: 1,
     _maxListeners: Infinity,
     connecting: 
      Promise {
        _bitField: 268566529,
        _fulfillmentHandler0: undefined,
        _rejectionHandler0: undefined,
        _progressHandler0: undefined,
        _promise0: undefined,
        _receiver0: undefined,
        _settledValue: [Circular],
        _boundTo: [Circular] },
     closing: false,
     retries: 0,
     maxRetries: 5,
     host: 'localhost',
     port: 2424,
     username: 'admin',
     password: 'admin',
     servers: [ [Object] ],
     currentServer: 0,
     enableRIDBags: true,
     useToken: false,
     token: <Buffer >,
     sessionId: 19,
     logger: 
      { error: [Function: bound bound ],
        log: [Function: bound bound ],
        debug: [Function] },
     connection: 
      Connection {
        domain: null,
        _events: [Object],
        _eventsCount: 3,
        _maxListeners: Infinity,
        host: 'localhost',
        port: 2424,
        socket: [Object],
        logger: [Object],
        enableRIDBags: true,
        closing: false,
        reconnectNow: false,
        protocol: [Object],
        queue: [],
        writes: [],
        remaining: null,
        connecting: false,
        protocolVersion: 32 },
     skipServerConnect: true },
  config: 
   { get: [Function: bound ],
     set: [Function: bound ],
     list: [Function: bound ] },
  domain: null,
  _events: 
   { reset: 
      [ [Function: bound ],
        [Function: bound ],
        [Function: bound ],
        [Function: bound ],
        [Function: bound ] ] },
  _eventsCount: 1,
  _maxListeners: Infinity }

ユーザー名とパスワードの変更を確認できます。サーバーを再度使用したい場合は、次のエラーが表示されます。

Unhandled rejection OrientDB.RequestError: Server user not authenticated.

ところで。新しいユーザー名とパスワードは、データベースのログイン データです。次のようにデータベースに接続します。

orientserver.use({
            name: req.params.database,
            username: username,
            password: password
        });
4

0 に答える 0