Hi Arne,
I'm no expert, but as per my experience, the results from OrientDB will
contain metadata such as @type, @class etc.
How I solved the problem was to pass through the OrientDB results via a
JavaScript function, create a JavaScript object as per the schema I want
and return the stringified version of the JavaScript object that I've
created.
Note: You can use the JSON.stringify() function to convert a JavaScript
object to JSON. However, I experienced the function not working on Java 1.8
- update 40.
Hope this helps.
Cheers
Omega
On Thursday, May 14, 2015 at 10:21:06 PM UTC+5:30, Arne Pfeilsticker wrote:
>
> 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.