Is there an efficient way in MongoDB to search for the presence of new data, such as a phone number, and insert it into another collection if it does not already exist? For example, searching whether the phone numbers [123456789, 15, 20] associated with a user already exist. If numbers 15 and 20 do not exist in the database collection, I need to be able to identify this so I can insert them into another collection. I am looking for a solution that minimizes queries to the database for efficiency.
User Collection
{
"_id" : "mJPqhyyGoeyfa3p2w",
"createdAt" : ISODate("2015-11-30T22:33:27.649Z"),
"phone" : {
"number" : "123456789",
"verified" : true
},
"profile" : {
"picture" : "xx",
"name" : "User IOS Mobile"
}
}