Search code examples
javascriptnode.jsorientdborientjs

Troubleshooting basic issues with orientjs (OrientDB driver for node.js)


I'm trying to test the latest version of orientjs with the 2.2 GA version of OrientDB. Using the very simple code below, I get no errors or exceptions, but also no output from the callback functions. I also don't see anything in the OrientDB server logs (which is running on the local server and is accessible via the web GUI).

var OrientDB = require('orientjs');

try {
  var server = OrientDB({
    host: 'localhost',
    port: 2424,
    username: 'admin',
    password: 'admin'
  });
} catch(error) {
  console.error('Exception: ' + error);
}

console.log('>> connected');

try {
  server.list()
  .then(function(dbs) {
    console.log(dbs.length);
  });
} catch(error) {
  console.error('Exception: ' + error);
}

try {
  var db = server.use({
   name: 'GratefulDeadConcerts',
   username: 'admin',
   password: 'admin'
  });
} catch(error) {
  console.error('Exception: ' + error);
}

console.log('>> opened: ' + db.name);

try {
  db.class.list()
  .then(function(classes) {
    console.log(classes.length);
  });
} catch(error) {
  console.error('Exception: ' + error);
}

db.close()
.then(function() {
  server.close();
});

How do I go about troubleshooting this issue?


Solution

  • I think user and password are wrong.

    Btw if you want to catch error you should use promises catch instead of try/catch block

      var OrientDB = require('orientjs');
      var server = OrientDB({
        host: 'localhost',
        port: 2424,
        username: 'admin',
        password: 'admin'
      });
    
      server.list()
      .then(function(dbs) {
        console.log(dbs.length);
      }).catch(function(error){
        console.error('Exception: ' + error);    
      });
    

    What happens with this script?

     var OrientDB = require('orientjs');
      var server = OrientDB({
        host: 'localhost',
        port: 2424,
        username: 'root',
        password: 'root'
      });
    
      var db = server.use({
       name: 'GratefulDeadConcerts',
       username: 'admin',
       password: 'admin'
      });
    
    
    
    
      db.query('select from v limit 1')
      .then(function(results) {
      console.log(results)
        server.close();
    
      }).catch(function(error){
          server.close();
      });