I have 2 object arrays, one of them is the one composed of emails that comes from the provider through IMAP protocol and I convert to objects and then put them in an array all of them.
The other is an array of emails that I look for in MongoDB and have the same structure as the first email, for example:
{
"_id" : ObjectId("59af03cb4a202223c4cf7bea"),
"idEmail" : "DM5PR13MB10209695536A9A5B3119967CCD960@DM5PR13MB1020.namprd13.prod.outlook.com",
"remetente" : "[email protected]",
"destinatario" : "[email protected]",
"assunto" : "Teste de gravação no banco",
"texto" : "Email diferente para gravar no banco\n",
"box" : "INBOX"
}
What I want to do is a function that compares the two arrays, do not delete anything from the DB, just save the differences (in this case the most recent emails coming from the provider).
But the two arrays are not the same size, the array that comes with the new emails will always be larger than the one already in the DB.
What I need (and I'm trying to do) is: Compare the two arrays and add only the differences in MongoDB.
I've already researched a lot and so far I have not found anything that solved my problem ...