Hello!,
I’m using Couchbase-server 5.0.1-5003-community I have a schema as such:
{
"_id": "xxx-xxx-xxx",
"type": "foo",
"targets": [
{
"label": "xyz",
"code": "001"
},
{
"label": "abc",
"code": "002"
}
]
}
Currently the value of targets is inputed directly. The items of the targets array may change in future, which means One would need to run an update query for every occurrence, which isn’t a good idea. So Instead I want to move the targets, into their own separate documents with schema:
{
"id": "xxx-xxx-xxx",
"type": "target",
"label": "xyz",
"code":"001"
}
And reference meta().id in the foo documents:
{
"_id": "xxx-xxx-xxx",
"type": "foo",
"targets": [
"target_001",
"target_002"
]
}
The values of the targets array above are document keys to the target doc.
How can run a N1QL on the above document(s) to resolve the following schema?:
{
"_id": "xxx-xxx-xxx",
"type": "foo",
"targets": [
{
"label": "xyz",
"code": "001"
},
{
"label": "abc",
"code": "002"
}
]
}