OrientDB.ConnectionError [10] code example

Example 1: OrientDB.ConnectionError [10]

const boostrap = pool => {
  app.use((req, res, next) => {
    pool
      .acquire()
      .then(session => {
        res.locals.db = session;
        res.on('end', () => {
          console.log('end : closing db session...');
          if (session) {
              session.close();
              session = null;
          };
        });
        res.on('close', () => {
          console.log('close : closing db session...');
          if (session) {
              session.close();
              session = null;
          };
        });
        res.on('finish', () => {
          console.log('finish : closing db session...');
          if (session) {
              session.close();
              session = null;
          };
        });
        next();
      })
      .catch(err => {
        console.log('err : closing db session...');
        if (session) {
            session.close();
            session = null;
        };
        res.status(500).send(err);
      });
  });

Example 2: OrientDB.ConnectionError [10]

const client = new OrientDBClient({
  host: "odbhost",
  db: "userDBName",
  user: "userId",
  password: "userPassword",
  rootUser: "rootId",
  rootPassword: "rootPassword",
  pool: {
    max: 200
  },
  logger: { debug: console.log.bind(null,"OrientDB: ") }
});

... bunch of stuff here, then :


  client
    .connect()
    .then(() => {
      return client.sessions({
        name: "userDBName",
        user: "userId",
        password: "userPassword",
        rootUser: "rootId",
        rootPassword: "rootPassword",
        pool: {
          max: 25
        },
        logger: { debug: console.log.bind(null,"OrientDB: ") }
      });
  })
  .then(pool => {
    console.log('loading bootstrap pool ...')
    boostrap(pool);
  })
  .catch(err => {
    console.log(err);
  });

Tags:

Misc Example