I have an existing collection (5k records already in production) in mongodb like below
//authors collection
[{
"name": "xyz",
"books": [
{
id: "123",
title: "some title"
},
{
id: "456",
title: "some title"
},
{
id: "789",
title: "some title"
}
]
},
{
name: "abc",
"books": [
{
id: "432",
title: "my book"
}
]
}
]
// books collection
[
{
id: "123",
title: "some title",
date: "relase date"
edition: "4th edition"
authors: [] //new key and need to populate this from the authors collection
}
//and so on
]
In the above books collection, I need to populate authors from the 'authors' collection. It is an existing database with the above structure and has around 5k records in mongodb collection.
Each book can have multiple authors!
What will be the most efficient way to achieve this?