M
M
Maks Hayovets2021-06-26 21:10:20
MongoDB
Maks Hayovets, 2021-06-26 21:10:20

How to combine(union all) two collections in one collection?

for example I have collection one with this data:

"_id": "60d75ed08af96529bf605030"
"Fname": "some name"
"Lname": "some last name"
"Age": "20"
"sex": "Woman"
"Previous_job": "Arsen"
"worksInShifts": "undefined"
"ShopAddress": "Shevchenka 43"
"NumberOFCashRegister": "8"
"__v":  "0"


and collection two with this data:

"_id": "60d75ed08af96529bf605030"
"Fname": "some name"
"Lname": "some last name"
"Age": "20"
"sex": "Woman"
"Previous_job": "Arsen"
"worksInShifts": "undefined"
"ShopAddress": "Shevchenka 43"
"NumberOFCashRegister": "8"
"__v":  "0"


(yes, these collections is the same)
I know how I can make it in MySQL using UNION ALL but I don't know how to make it in mongo db,
how can I combine these collections in one collection?
can give answer in Russian or Ukraine

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
vbg8tmtm, 2021-07-01
@vbg8tmtm

Since version 4.4, the unionWith operation has appeared there https://docs.mongodb.com/manual/reference/operator...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question