@vsr1 I tried this solution inside of for loop like below and getting timeout erors alot.
I am trying to bulk insert documents based on result query in a executing eventing function.
Do you see any better way of doing this.
data = query result;
for (var val of data) {
if (!val.historyid && !val.id) {
log(‘no records to insert into history’);
break;
}
var historyID = val.historyid;
var vID = val.id;
// insert into history with instanceRef from data
INSERT INTO hist (KEY UUID(), VALUE OBJECT_PUT(docx, "refrencefield", $vID))
SELECT d AS docx FROM hist AS d WHERE d.id = $historyID;
log('insert successful', vID);
}