1

I'm new on orientdb and I would like to know if is possible to insert a document with three levels of depth, using a embedded inside another embedded, like the example under. I've being searching for some examples like my data with no success. Example:

"p_partkey": 1,
"p_name": "lace spring",
"lineorder": [{
    "lo_revenue": 4282453,
    "lo_orderdate": 19920603,
    "customer": [{
        "c_nation": "JORDAN",
        "c_address": "uZaxFV8o9IGgayUEWtPU1Xmw",
        "c_mktsegment": "BUILDING|"
    }],
    "orderdate": [{
        "d_date": "June 3, 1992",
        "d_datekey": 19920603,
        "d_year": 1992
    }]},{
    "lo_revenue": 46868767,
    "lo_orderdate": 9987983,
    "customer": [{
        "c_nation": "BRAZIL",
        "c_address": "kjbnkjakjh",
        "c_mktsegment": "BUILDING|"
    }],
    "orderdate": [{
        "d_date": "June 6, 1994",
        "d_datekey": 19940606,
        "d_year": 1994
    }]}]

All examples I've found uses only one level of embedded documents. I've being using:

INSERT into part CONTENT {json data}

But it creates only one embedded type on lineorder.

Raphael
  • 99
  • 10

1 Answers1

1

I have created 3 class ( A, B, C )

I use these query :

insert into A content { "embedded_B" : { "@type":"d", "@class":"B", "name" :"myRecord_B", "embedded_C" : { "@type":"d", "@class":"C", "name" :"myRecord_C" }}}

enter image description here

select embedded_B.name as name,embedded_B.type() as type from A

enter image description here

select embedded_B.embedded_C.name as name,embedded_B.embedded_C.type() as type from A

enter image description here

Hope it helps.

Alessandro Rota
  • 3,560
  • 1
  • 8
  • 10
  • @Aleesandro Rota did you create the classes before the insert or only on insert? – Raphael Mar 30 '16 at 15:02
  • @Raphael I created classes A, B and C before the insert without any field – Alessandro Rota Mar 30 '16 at 15:12
  • I've tried your solution, but it works with only one object of class B. If I have more than one object of class B it don't work. Example: { "embedded_B" : { "@type":"d", "@class":"B", "name" :"myRecord_B1", "embedded_C" : { "@type":"d", "@class":"C", "name" :"myRecord_C2" }},"embedded_B" : { "@type":"d", "@class":"B", "name" :"myRecord_B2", "embedded_C" : { "@type":"d", "@class":"C", "name" :"myRecord_C2" }}} – Raphael Apr 17 '16 at 00:10