N1QL query to insert from resultset and add uuid as id to the document

@vsr1

data = [ { “historyid”: “47b”, “id”: “6b9” }, { “historyid”: “47b”, “id”: “c40” }…]

I am trying to insert new document by selecting data with id= historyid and and insert a new document from resultset with new id=uuid()

data = select * from hist where id = historyid

INSERT INTO hist
SELECT * from hist AS doc where id = historyid;
how can I add uuid as id in the insert

INSERT INTO hist (KEY UUID(), VALUE doc)
SELECT d AS doc 
FROM hist AS d
WHERE ...............;

https://docs.couchbase.com/server/current/n1ql/n1ql-language-reference/insert.html#insert-examples

thanks @vsr1
forgot to add — apart from adding uuid I need to update ref field with id from data

INSERT INTO hist (KEY UUID(), VALUE OBJECT_PUT(doc, "refrencefield",  "xyz"))
SELECT d AS doc 
FROM hist AS d
WHERE ...............;

thanks again @vsr1
marked as solution