node.jsorientdborientdb2.2orientdb-2.1orientjs

Orientdb query approach to get properties of vertices and edges


Im a newbie to orient db .I have a vertex user which has properties adress,name and another vertex Images with properties imagename,date.Both are connected by and edge postedby.Now I want to write a query to select all images posted by a user with all the properties of both the vertices.How can I write the query to get this.I use orientjs in my project


Solution

  • Try this:

    var OrientDB = require('orientjs');
    var db = OrientDB({
    host: 'localhost',
    port: 2424,
    });
    var db = db.use({
    name: '<db name>',
    username: '<username>',
    password: '<pwd>'
    });
    db.query('select address, name, out("postedby").imagename as imagename, out("postedby").date as date from User where name = "<insert a name>" unwind imagename,date')
    .then(function (response) {
    console.log(response);
    });
    db.close();
    

    Hope it helps

    Regards