orientdborientjs

How to use array results from orientjs query in another query - array is not an "array"


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?


Solution

  • Hi oliver in_filedIn is not an Array is a structure called RidBag in Orientjs the implementation is done in Bag.js. If yo want to get the array you should do

    result['in_filedIn'].all()
    

    to get the array.