Search code examples
mysqlnode.jsorientdb

How to make a Queries from the server in Node.js to the database OrientDB


My question is:

  • How do you make Queries from the Server to the Database?

I have been reading some articles and seeing some tutorials from Udemy about OrientDB, I found about what is a Query Language, like SQL, but I couldn't find how to send a Query from the Server to the DataBase OrientDB . I am making the server in Node.js.

I found how to start the connection and close it:

var OrientDB = require('orientjs');

var server = OrientDB({
host:       'localhost',
port:       8082,  //I am using the port 8081 for Binary and 8082 for Http
username:   'root',
password:   'rootPassword'
});

server.close();

I have been reading the OrientDB Documents but I couldn't find it. http://orientdb.com/docs/last/index.html


Solution

  • all you need is just search in the official documentation

    http://orientdb.com/docs/last/OrientJS.html

    http://orientdb.com/docs/last/OrientJS-Database.html

    var targetAvg = 0.3;
    var targetTeam = 'Red Sox';
    
    var hitters = db.query(
       'SELECT name, battavg FROM Player WHERE battavg >= :ba AND team = :team',
       {params: {
          ba: targetAvg,
          team: targetTeam
        },limit: 20 }
    ).then(
       function(players){
          console.log(players);
       }
    );