eric
eric

Reputation: 533

Update OrientDB EmbeddedMap Value via SQL

Two related issues:

1) I can set (i.e. completely replace the content of an EmbeddedMap field) with this statement:

update #14:1 set Options = {"555":{"Action":"Test555","Enabled":false},"444":{"Action":"Test444","Enabled":false}}

But I can add or update a value, for example:

update #14:1 add Options = {"222":{"Action":"Test222","Enabled":false},"333":{"Action":"Test333","Enabled":false}}

2) I can't seem to figure out a syntax for setting the EmbeddedMap field along with the other fields in the record while creating it.

I've searched high and low for examples of these, and experimented with every variant I could think of, but haven't had any luck on either front. Any advise would be greatly appreciated.

Upvotes: 1

Views: 237

Answers (1)

Alessandro Rota
Alessandro Rota

Reputation: 3570

You can use

update #14:1 put Options = '222', {"Action":"Test222","Enabled":false}

enter image description here

EDIT

I used 2.2.0GA

I used these commands:

create class MyClass extends V
insert into MyClass(name) values("test")
update #21:0 set Options = {"555":{"Action":"Test555","Enabled":false},"444":{"Action":"Test444","Enabled":false}}
update #21:0 put Options = '222', {"Action":"Test222","Enabled":false}
select from MyClass

enter image description here

EDIT 2

create property MyClass4.Options EmbeddedMap V
insert into MyClass4(name) values("test4")
update #34:0 set Options = {"555":{"@type":"d", "@class":"V","Action":"Test555","Enabled":false},"444":{"@type":"d", "@class":"V","Action":"Test444","Enabled":false}}
update #34:0 put Options = '222', {"@type":"d", "@class":"v","Action":"Test222","Enabled":false}

enter image description here

Hope it helps.

Upvotes: 0

Related Questions