I have a tree structure which looks like:
id,parent_id,label
pt,,Rechtssubjekt
pt.1,pt,natürliche Person
pt.2,pt,juristische Person
pt.21,pt.2,juristische Person des Privatrechts
pt.22,pt.2,juristische Person des öffentlichen Rechts
...
I get in the Studio-Browser with: select from PersonTypes where @rid = #12:0
fetchplan out_*:-1
{
"result": [
{
"@type": "d",
"@rid": "#12:0",
"@version": 3,
"@class": "PersonTypes",
"id": "pt",
"parent_id": null,
"label": "Rechtssubjekt",
"out_hasPersonSubtype": [
{
"@type": "d",
"@rid": "#11:0",
"@version": 3,
"@class": "hasPersonSubtype",
"out": "#12:0",
"in": {
"@type": "d",
"@rid": "#12:1",
"@version": 2,
"@class": "PersonTypes",
"id": "pt.1",
"parent_id": "pt",
"label": "natürliche Person",
"in_hasPersonSubtype": [
"#11:0"
],
"@fieldTypes": "in_hasPersonSubtype=g"
},
"@fieldTypes": "out=x"
},
{
"@type": "d",
"@rid": "#11:1",
"@version": 3,
"@class": "hasPersonSubtype",
"out": "#12:0",
"in": {
"@type": "d",
"@rid": "#12:2",
"@version": 4,
"@class": "PersonTypes",
"id": "pt.2",
"parent_id": "pt",
"label": "juristische Person",
"in_hasPersonSubtype": [
"#11:1"
],
"out_hasPersonSubtype": [
{
"@type": "d",
"@rid": "#11:2",
"@version": 3,
"@class": "hasPersonSubtype",
"out": "#12:2",
"in": {
"@type": "d",
"@rid": "#12:3",
"@version": 2,
"@class": "PersonTypes",
"id": "pt.21",
"parent_id": "pt.2",
"label": "juristische Person des
Privatrechts",
"in_hasPersonSubtype": [
"#11:2"
],
"@fieldTypes": "in_hasPersonSubtype=g"
},
"@fieldTypes": "out=x"
},
...
What i would like to have ist something like this:
{
"result": [
{
"id": "pt",
"parent_id": null,
"label": "Rechtssubjekt",
"children": [
{
"id": "pt.1",
"parent_id": "pt",
"label": "natürliche Person",
"children": [
],
},
},
{
"id": "pt.2",
"parent_id": "pt",
"label": "juristische Person",
"children": [
{
"id": "pt.21",
"parent_id": "pt.2",
"label": "juristische Person des
Privatrechts",
"children": [ ],
},
},
...
Is there any chance to get something like this with a SQL command or server
side function?
For any advice or examples I am grateful.
Can it be that fetchpans do not work in server-side functions?
--
---
You received this message because you are subscribed to the Google Groups
"OrientDB" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.