Korzystanie z .aggregate()
metoda i $setUnion
operatora.
db.collection.aggregate([
{ "$project": {
"attribute3": { "$setUnion": [ "$attribute1", "$attribute2" ] }
}}
])
Co daje:
{
"_id" : ObjectId("52f0795a58c5061aa34d436a"),
"attribute3" : [8, 4, 2, 6, 3, 7, 1]
}