2
votes

With orientDB you can insert / update directly using JSON as the input using the 'CONTENT' keyword which is great. ODB takes care of the mappings.

Id like to be able to return JSON as well from SELECT queries - is this possible?

Kurt

1

1 Answers

3
votes

You can use .toJSON() method.

Syntax: <value>.toJSON([<format>])

Example:

create class Test extends V
insert into Test content {"attr1": "value 1", "attr2": "value 2"}

select @this.toJson('rid,version,fetchPlan:in_*:-2 out_*:-2') from Test

Ref.: SQL Methods - .toJSON()