1

I want to use an array-like result from a query, but am having trouble. I have:

class case extends V
class doc extends V
class filedIn extends E

So, a document is filed in a class via an edge of class filedIn.

My first query pulls a set a vertices:

.select().from('case').one().then(function(result){...

I then want to select all the filedIn edges linking to any of those case vertices, but how?

JSON.stringify(result)

{"@type":"d","@class":"matter","title":"my case","in_filedIn":["#17:7","#17:8","#17:9"],"@rid":"#12:3","@version":12}

looks like result['in_filedIn'] is an array,

but

.select().from(result['in_filedIn']).all()

gets me this error from back from the database:

Error on parsing command at position #0: Error parsing query: \nSELECT * FROM [object Object]\nEncountered \

select().from('[#17:7,#17:8,#17:9]')

(hard coded) works.

.select.from("[" + ["#17:1","#17:2].join(',') + "]").all()

also works.

but

select.from("[" + result['in_filedIn'].join(,)+"]").all()

throws

result.in_filedIn.join is not a function

I.e. whatever kind of object it is, it's not inheriting from the Array prototype.

console.log(result['in_filedIn'])

produces:

Bag { serialized: >'AQAAAAUAEQAAAAAAAAAHABEAAAAAAAAACAARAAAAAAAAAAkAEQAAAAAAAAAKABEAAAAAAAAADwAAAAA>AAAAAAAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA', uuid: null, _content: [ { [String: '#17:7'] cluster: 17, position: 7 }, ...

So I'm rather puzzled what to do.

I want to select all the edges whose @rid is listed in result.in_filedIn

Or have I misunderstood something?

4

3 回答 3

4

嗨 Oliver in_filedIn 不是数组,它是 Orientjs 中称为 RidBag 的结构,实现是在 Bag.js 中完成的。如果你想得到你应该做的数组

result['in_filedIn'].all()

获取数组。

于 2016-02-12T09:57:04.270 回答
0

我实际上有一个类似的问题。当您实例化您的数据库连接时,有一个配置字段他们没有在他们的文档中列出,称为enableRIDBags. 所以你的配置看起来像: { host: 'localhost', port: 2424, username: 'blah', password: 'blooh', enableRIDBags: false } 我发现最好禁用 RIDBags,因为它们在节点中有点挑剔。上面列出的 .all() 技巧对我来说效果很好,直到我的顶点有超过 40 条边,然后它们都被转换为 SBTree 包而不是嵌入式包。如果您在此处检查第 122 行,您会看到当您调用时它们无法将树转换为 JSON.all()

于 2017-05-17T12:39:22.540 回答
0

以下工作,虽然它有点脏。

.from(JSON.stringify(result['in_filedIn']).replace(/"/g,""))

我还在寻找更好的答案!

于 2016-02-12T10:11:14.067 回答