Reputation: 98
I am getting results from a aggregate query on a collection called "fileprocessingrequest". I trying to merge a field AssetIDArray(array) from the result of "fileprocessingrequest" collection to another collection called "subscriber" which consists of a field dvr_id(Array). It should not allow duplicate ID's to merge
I am trying to figure out how to merge the AssetID array into dvr_id array without duplication of records.
Below is the result of aggregate on fileprocessingrequest collection
[{"AssetIDArray":["SID_BIGBANG_2ACF","SID_BIGBANG_2ACD","SID_BIGBANG_2ACC","SID_BIGBANG_2ACB"],"count":7}]
The subscriber collection result looks like this
[{"_id":"5cca2a6a1055de2ff407d4c3","dvr_id":["SID_BIGBANG_2ACF","SID_BIGBANG_2ACD"]}]
I expect the array in "fileprocessingrequest" collection to merge with the array in "subscriber" collection without duplication. I am not able to figure out how I can do that.
Upvotes: 0
Views: 35
Reputation: 869
const setId = new Set([...AssetIDArray, ...dvr_id]);
const uniqArr = Array.from(_set);
Upvotes: 1