How can i update whole doc but still preserve some old data

I use the N1QL UPSERT to update my Docs in the Couchbase. Here is the issue i am running into, i keep a history object under my Documents. So if i create a document its simple as there is no prior history, but if I do an update i don’t want to completely overwrite the history which would mean i lose the created info.
For now i go and get the old history object and then add the updated info to it before i update the doc via set and upsert.

So i am wondering if there is a more effective way short of setting every key and value vs setting whole doc.

I’m not sure I follow your request entirely. The SET clause of the UPDATE statement could be used to update individual fields; UPSERT is for whole document updates.

Commonly the application will know if it is updating an existing document (as it will have fetched it previously) or inserting a new document, allowing it to readily chose INSERT or UPDATE as appropriate.

HTH.