Include keys in array output

Hello,
I am running the below query:

select array [e.description, e.timestamp] for e in results.events end as data
from `test`.`_default`.`_default` 
where meta().id="event::1";

which is producing the below output:

[
  {
    "data": [
      [
        "added 1",
        "2023-11-28T08:59:33.056000+0000"
      ],
      [
        "1 came up",
        "2023-11-28T08:59:33.242000+0000"
      ],
      [
        "1 completed",
        "2023-11-28T08:59:37.342000+0000"
      ],
      [
        "1 processed",
        "2023-11-28T08:59:47.734000+0000"
      ],
      [
        "2 processed",
        "2023-11-28T08:59:47.757000+0000"
      ]
    ]
  }
]

Is there any way to convert the above array output to JSON and include keys in it?
My desired output is:

[
  {
    "data": [
      {
        "description": "added 1",
        "timestamp": "2023-11-28T08:59:33.056000+0000"
      },
      {
        "description": "1 came up",
        "timestamp": "2023-11-28T08:59:33.242000+0000"
      },
      {
        "description": "1 completed",
        "timestamp": "2023-11-28T08:59:37.342000+0000"
      },
      {
        "description": "1 processed",
        "timestamp": "2023-11-28T08:59:47.734000+0000"
      },
      {
        "description": "2 processed",
        "timestamp": "2023-11-28T08:59:47.757000+0000"
      }
    ]
  }
]

You can try this query:

SELECT ARRAY { e.description , e.timestamp }
FOR e IN results.events END AS data
FROM `test`.`_default`.`_default` 
WHERE meta().id = "event::1";

the key is meta().id

I that is ambiguous, meta(<keyspace>).id

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.