Hello,
Can you help me retrieving the referenced content from a list of references ?
The scope of this data structure is to create a dictionary of json forms with exchangeable fields and values.
I have 3 types of docs : form (which may contain an array of references to subForms and an array of references of fields), field (which which may an array of references to values) and value (which may contain an array of references to other subValues ).
A form looks like :
{
“content”: {
“fields”: [
{“ref”: “field_0”},
{ “ref”: “field_1”},
{ “ref”: “field_2”}
],
“subForms”:[
{“ref”: “form_1”}
]
“label”: “exemple form”,
“name”: “form_0”,
“ref”: “form_0”
},
“dbId”: “FORM::form_0”,
“type”: “FORM”
}
A field looks like :
{
"content": {
"values": [
{ "ref": "value_0" },
{ "ref": "value_1" }
],
"label": "field test ",
"name": "field_0",
"ref": "field_0"
},
"dbId": "FIELD::field_0",
"type": "FIELD"
}
Then a value looks like :
{
“content”: {
“subValues”: [
{ “ref”: “value_2” }
],
“label”: “value test”,
“name”: “value_0”,
“ref”: “value_0”
},
“dbId”: “VALUE::value_0”,
“type”: “VALUE”
}
I’m trying to find out a query to get as result a form completely fulfilled, in practice each “ref” should be replaced by the corresponding “content”. I’m new to N1QL, I tried different queries with NEST and JOIN clause but I’m unable to obtain the following result :
{
"content": {
"ref": "form_0",
"label": "exemple form",
"name": "form_0",
"fields": [
{ "ref": "field_0",
"label": "field test ",
"name": "field_0",
"values": [
{ "ref": "value_0",
"label": "value test",
"name": "value_0",
"subValues": [
{ "ref": "value_1",
"label": "value1 test",
"name": "value_1",}
],
},
{ other values ...}
],
},
{other fields...}
],
"subForms":[
{other forms...}
]
}
}
Any help would be appreciated, thanks.