How can I rename field of document with N1QL?

n1ql

#1

Hello,

I’ve got:

{
   "id": "12345",
   "docType": "Car" 
}

I need to rename “id” field to “carId” and get this:

{
   "carId": "12345",
   "docType": "Car"  
}

What n1ql query can do that?

Thanks for any help


#2

Hi, you can do

UPDATE mybucket
SET carId = id
UNSET id
;

You can also add a WHERE clause if needed.