I want to query couchbase data using plain SQL query from the couchbase console.
The oop schema will be like this.
Original:
class travel-sample{
//all properties
List schedule;
}
class Schedule{
//all properties
}
Need to project travel-sample like this in a separate class:
class travel-sample-another{
//some properties
List schedule;
}
class Schedule-another{
//some properties
}
Following are documents:
Document:
[
{
“travel-sample”: {
“airline”: “AF”,
“airlineid”: “airline_137”,
“destinationairport”: “MRS”,
“distance”: 2881.617376098415,
“equipment”: “320”,
“id”: 10000,
“schedule”: [
{
“day”: 4,
“flight”: “AF818”,
“utc”: “08:02:00”
},
{
“day”: 5,
“flight”: “AF967”,
“utc”: “11:33:00”
},
{
“day”: 5,
“flight”: “AF730”,
“utc”: “19:42:00”
}
],
“sourceairport”: “TLV”,
“stops”: 0,
“type”: “route”
}
}
]
How to query to get results like this:
[
{
“travel-sample”: {
“airline”: “AF”,
“airlineid”: “airline_137”,
“destinationairport”: “MRS”,
“schedule”: [
{
“flight”: “AF818”,
“utc”: “08:02:00”
},
{
“flight”: “AF967”,
“utc”: “11:33:00”
},
{
“flight”: “AF730”,
“utc”: “19:42:00”
}
],
“sourceairport”: “TLV”,
“type”: “route”
}
}
]
We could see day property is not in the array of the map for schedule and so on. I want exact this format efficiently. I am new to the couchbase. Maybe UNNEST, NEST or Iteration can help, however, I couldn’t get the way to retrieve exactly this result. Just plain sql query will be good for me. I will take care of other stuff. Thank you in advance.