B
B
beduin012020-06-23 17:15:54
MongoDB
beduin01, 2020-06-23 17:15:54

How to combine documents into collections?

I have documents that are broken into parts. Everything looks like this:

{
 "id": "371"
 "name": "Mike",
 "location": "Paris"
},
{
 "id": "371-1",
 "age": 20,
 "lastname": "Piterson"
}


I need to merge them based on `id` to get one final document. How to do it?
You should get a document like:

{
 "id": "371"
 "name": "Mike",
 "location": "Paris"
 "age": 20,
 "lastname": "Piterson"
}

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question