iLemming
iLemming

Reputation: 36166

How do I project into an object

If I have a query like this

SELECT part, meta(loc).id FROM `bucket` as loc 

it results into something like:

[{
   "id": "loc_006b9cfc1ef849f68b694e35c99c4dfe",
   "part": {
            "name": "foo",
            "partNumber": "1806-0085S"
           },
 } ...

but what if I want something like this:

SELECT part, { meta(loc).id } FROM `bucket` as loc  // won't work of course

that I would like to results into:

[{
   // see, this guy wrapped in its own object
   { "id": "loc_006b9cfc1ef849f68b694e35c99c4dfe" },  
   "part": {
            "name": "foo",
            "partNumber": "1806-0085S"
           },
 } ...

Upvotes: 1

Views: 42

Answers (1)

geraldss
geraldss

Reputation: 2445

You can use:

SELECT part, { "id": meta(loc).id } AS some_alias
FROM `bucket` as loc

Upvotes: 2

Related Questions