I'm trying to do the orientjs and express 4 integration. I'm confusing with how to make a route to index.js.
Since orientjs has just launced, I still can't find any tutorial.
Now I just want to make a simple select from the orientdb.
Could anyone please give me some suggestions?
Thank you
You first need to import orientjs in your express application for which you can do
npm install orientjs --save
After this require orientjs and create a connection to the orientDb.
var orientJs = require('orientjs');
var orientDb = OrientJs({
host: "yourhostName",
port: "orientdb Port ",
username: "OrientDB user Name",
password: "password"
});
Now specify the database you want to connect to
var db = orientDb.use({
name: 'database name',
username: 'database user',
password: 'password'
});
Once that is done you can use "db" to run your query. Now you can use raw query or orientjs query builder to write your query.
This can be done like
db.select().from(className).all().then(funtion(res){
console.log(res);
},function(err){
console.log(err);
});