How to merge an array of objects to an exiting document that has array of objects

Hi,
I need merge an array of objects to an exiting document that has array of objects.

Each document in the bucket consists of array of objects. These array can have 100,000 objects.
I need to merge the existing array with new array based on sys_id.
If sys_id from the new array exists in the couchbase replace the object in the document (array)
if sys_id from the new array does not exist in the couchbase append the object in the document (array)

The sample document is:
“default”: [
{
“sys_created_by”: “a111”,
“sys_created_on”: “2016-08-31 10:41:08”,
“sys_id”: “002491c24fe5a200dad146501310c712”,
“sys_mod_count”: “0”,
“sys_tags”: “”,
“sys_updated_by”: “a111”,
“sys_updated_on”: “2016-08-31 10:41:08”,
“u_access_technology”: “”,
“u_adbor_id”: “”,
“u_address”: “”,
“u_avc_id”: “”,
“u_city”: “”,
“u_ssu”: “”,
“u_state”: “ACTIVE”,
“u_uni_port_id”: “”,
“u_uni_type”: “”
},
{
“sys_created_by”: “d11111”,
“sys_created_on”: “2016-09-02 01:34:12”,
“sys_id”: “002a61e64fa1e200dad146501310c782”,
“sys_mod_count”: “0”,
“sys_tags”: “”,
“sys_updated_by”: “d11111”,
“sys_updated_on”: “2016-09-02 01:34:12”,
“u_access_technology”: “”,
“u_adbor_id”: “”,
“u_address”: “”,
“u_avc_id”: “”,
“u_ssu”: “”,
“u_state”: “ACTIVE”,
“u_uni_port_id”: “”,
“u_uni_type”: “”
}
]

Your help will be much appreciated.

Can you take a look at N1QL. Also, please add a N1QL tag or category to the posting.