Kurt Maile
Kurt Maile

Reputation: 1267

OrientDB - Return JSON from a Select query

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

Upvotes: 2

Views: 1235

Answers (1)

Oleksandr Gubchenko
Oleksandr Gubchenko

Reputation: 1369

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()

Upvotes: 3

Related Questions