Updating a embedded list in orient db using query
Asked Answered
T

2

0
update Orders ADD orders = [{
                "source":"A",
                "target": ["B", "C"]
                }] where id=1

I am trying to add some values into an embedded list, here the embedded list being orders, this is what I tried, but it doesn't seem to work.

Toilsome answered 12/8, 2020 at 4:55 Comment(0)
T
0

I tried this to insert some values to the embedded list

INSERT INTO SOrders SET orders = [{"source":"A","target": ["B", "C"]}, 
                                  {"source":"B","target": ["E", "F"]}
                                 ] where id = 1;
Toilsome answered 13/8, 2020 at 6:4 Comment(0)
N
0

In OrientDB 3.x, the 'ADD' option in UPDATE statement is not available

The way to add to set/list etc. is to use the SQL functions. Refer: SQL Function Reference.

In the above case, to add to a list the list() function could be used. Below is an example:

UPDATE #62:0 SET category=list(category,'y');

In the above example, if the category property has value, the value 'y' will be merged into the list. If category is not set 'y' will be set in a list

UPDATE #62:0 SET category=set(category,'y');

Similar to the above, set also can be inserted into.

Noncompliance answered 5/10, 2022 at 7:4 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.