Reputation: 4092
Select query doesn't work for JSON in OrientDB. Can someone provide with a working example showcasing two things:
Inserting JSON data correctly
Querying JSON data
Thanks!
Upvotes: 7
Views: 6882
Reputation: 450
1.Use "content" to implement JSON insert.
For Example-
insert into Person content {"name":"nawab","age":25}
for this to run,you must have prior configuration as-
1.Create a Vertex by-
create class Person extends V
2.Then Create Property name and age
create property Person.name string
create property Person.age integer
Upvotes: 4
Reputation: 2657
Here you go! I have been trying to figure this out for a while now and finally got it to work. :)
Run the following sql commands as displayed:
create class EXAMPLE
/* The trick is: Do not 'CREATE' the property with any type */
insert into EXAMPLE (my_prop) values ({"name": "James", "age": 23})
insert into EXAMPLE (my_prop) values ({"name": "Harden", "age": 24})
/* Fetch the fields inside the JSON */
select my_prop.name from example
select my_prop.age from example where my_prop.name like 'James'
I read this example from the book: Getting Started with OrientDB By Claudio Tesoriero
Hope it helps!
Upvotes: 3