I have a mongodb collection with around 4-5 million documents. It have a field with name "role": "admin". What I want to do is to convert all the roles to array i.e "role": ["admin"].
I prefer not to use forEach loop. Please help me with this. I am a bit new to mongodb.
old documents
{
"role": "admin"
}
{
"role": "mod"
}
to new documents
{
"role": ["admin"]
}
{
"role": ["mod"]
}