Taksan
Taksan

Reputation: 3

How to create an embeddedlist with Class type?

I'm using OrientDB 3.0.1

I created an embeddelist property using:

CREATE PROPERTY MyClass.property1 EMBEDDEDLIST

And everything works fine (reading, writing) using sql.

But, I want an embeddedlist of only documents of certain type, what I want is to do something like this:

CREATE PROPERTY MyClass.property2 EMBEDDEDLIST AnotherClass

And then I want to do this:

insert into MyClass content { "property2": [{ "@Class":"AnotherClass"...},{"@Class":"AnotherClass"...}]}

I get this error:

The field 'MyClass.property2' has been declared as EMBEDDEDLIST but an incompatible type is used

So, how can I force/validate that my embeddedList only accepts documents of a specific Class? Maybe using a Hook?

Update: it works now in Orient 3.0.2 (Thanks Luigi!) here is the solution:

create class OneClass extends V;
create property OneClass.myList embeddedlist Coordinates;

insert into OneClass set myList = [
                {
                    "@class": "Coordinates",
                    "latitude": 6511,
                    "longitude": 3
                },
                {
                    "@class": "Coordinates",
                    "latitude": 6518,
                    "longitude": 3
                }
];

Upvotes: 0

Views: 75

Answers (1)

Luigi Dell'Aquila
Luigi Dell'Aquila

Reputation: 2814

It is a bug in v 3.0.1 and is already fixed in v 3.0.2.

Upvotes: 0

Related Questions