Hi
I am trying to move an existing system over to Couchbase - and the data is structured in a traditional relational manner right now. I am making some changes but on the other hand try to limit the number of data changes to avoid too many side effects
So I have these two different types of documents CoastArea
and a number of CoastLocalArea
underneath the areas. All data is in the same bucket - just a different _Type
. How can I join the CoastArea.Name
into the list of CoastLocalArea
documents?
Ideally, I want to JOIN
the data to add an AreaName
to the CoastLocalArea
in the resultset.
Sample data:
{
"data": {
"Name": "Fanø",
"_Key": "179",
"_Type": "CoastArea",
"_Unid": "012389FEDDFE3E82C12582A4002F714F"
}
},
{
"data": {
"AreaKey": "179",
"Name": "Rindby Strand",
"Points": [
{
"Lat": 55.4219856355,
"Lon": 8.3677502154
},
{
"Lat": 55.3959022179,
"Lon": 8.3928679228
},
{
"Lat": 55.4194003476,
"Lon": 8.3704811983
}
],
"_Key": "1787",
"_Type": "CoastLocalArea",
"_Unid": "0216519C9A524EF5C12582A4002F715D"
}
},
{
"data": {
"AreaKey": "179",
"Name": "Skideneng",
"Points": [
{
"Lat": 55.4275494328,
"Lon": 8.4144364255
},
{
"Lat": 55.4261875559,
"Lon": 8.4183043138
}
],
"_Key": "1808",
"_Type": "CoastLocalArea",
"_Unid": "0BD53EAF6DB345B7C12582A4002F719C"
}
}, ...
All of the examples I have seen on joins use the FROM
clause to specify the two entities - as coming from different buckets…
The sample data above is returned from this query:
SELECT *
FROM data
WHERE (_Type ="CoastLocalArea" and AreaKey = "179") or (_Type ="CoastArea" and _Key = "179")
Any suggestions appreciated
/John