0

我正在使用OrientDB图形数据库,我有两个顶点 Room 和 Participant,我在 Room 和 Participant 记录之间创建了一些边,我想使用orientjs驱动程序执行以下命令:

select from (traverse out() from (select from room where name='room test 1')) where @class='Participant' 

更新

我想使用这样的东西:

db.let('firstSelect', function(s){
     s.select().from('room').where({name:'room test 1'});
}).let('traverse', function(s){
     s.traverse('out()').from('$firstSelect').while('$depth<=1');
}).let('finalSelect', function(s){
     s.select().from('$traverse').where({'@class':'Participant'});
}).commit()
.return('$finalSelect')
.all()
.then(function(participants){
    console.log(participants);
})

将来我会将这段代码放在一个带有一些参数的函数中

4

1 回答 1

0

您可以使用db.queryAPI:

var OrientDB = require('orientjs');

var server = OrientDB({
    host: 'localhost',
    port: 2424,
    username: 'root',
    password: 'root'
});

var db = server.use({
    name: 'OrientJStest',
    username: 'root',
    password: 'root'
});

db.query('select from (traverse out() from (select from room where name="room test 1")) where @class = :inputClass', {
    params: {
      inputClass: "Participant"
    },
    limit: -1
}).then(function (results) {
    console.log('Vertexes found: ');
    console.log();
    console.log(results);
});

希望能帮助到你

于 2016-05-10T02:35:30.660 回答