Database
[{"data":[{customId:22,customArr:[321,123]},{customId:33,customArr:[123]},{customId:22,customArr:[]}]}]
Query
db.collection.aggregate([{$project:{customId:{$setUnion:"$data.customId"},customArr:{$reduce:{input:"$data",initialValue:[],in:{$setUnion:["$$this.customArr","$$value"]}}}}}])