Below is my user collection data
user collection
{
"_id" : ObjectId("584bc9ba420a6b189c510af6"),
"old_user_id" :1,
"name" :"aaa"
},
{
"_id" : ObjectId("9ba420a584bc6b189c59ba42"),
"old_user_id" : 2,
"name" :"bbb"
},
{
"_id" : ObjectId("59ba4284bc0a6b189c3323w23"),
"old_user_id" : 3,
"name" :"ccc"
}
myprofile collection
{
"old_user_id" :1,
"name" :"aaa",
"number":"123456789"
},
{
"old_user_id" : 2,
"name" :"bbb",
"number":"678912345"
},
{
"old_user_id" : 3,
"name" :"ccc",
"number":"673458912"
},
{
"old_user_id" : 2,
"name" : "bbb",
"adress" : "afsfdidhddk"
}
My expectation:
I need to match old_user_id
in both collections and update the user
collection '_id' in my profile
collection
{
"userid":"584bc9ba420a6b189c510af6",
"old_user_id" :1,
"name" :"aaa",
"number":"123456789"
},
{
"userid":"9ba420a584bc6b189c59ba42",
"old_user_id" : 2,
"name" :"bbb",
"number":"678912345"
},
{
"userid":"59ba4284bc0a6b189c3323w23",
"old_user_id" : 3,
"name" :"ccc",
"number":"673458912"
},
{
"old_user_id" : 2,
"name" : "bbb",
"adress" : "afsfdidhddk"
"userid" : "9ba420a584bc6b189c59ba42"
}