Advise how to properly organize the data storage structure in Mongo. Input data E-mail, phone number and a unique number of the site visitor are stored in a cookie and, accordingly, may change for various reasons (n_id). Let’s say I receive n_id and phone number. I’m creating a Document. The second time I get n_id and email. I need to check, by E-mail and n_id, there is such a document that contains either this or that. If there is, then supplement it with the missing data. That is, 1 document can have 2 numbers, 10 n_id, and 5 email. When I thought 2 storage structures, maybe you can advise how best.
1.Variant
{
“_id”:
{"$oid": "5f56a52a9eafb85d4314c612"},
"created_at": {"$date": "2020-09-07T21:24:58.766Z"},
"data": [
{
"phone": 77777777,
"email": "1@1.ru",
"n_id": 12
},
{
"phone": 177777777,
"email": "11@1.ru",
"n_id": 112
}
],
"updated_at": {"$date": "2020-09-07T21:24:58.766Z"}
Second option
{"_id": {"$oid": "5f56a5ba9eafb862c7676c02"},
"created_at": {"$date": "2020-09-07T21:27:22.454Z"},
"updated_at": {"$date": "2020-09-07T21:27:22.454Z"},
"email": ["1@1.ru", "31@1.ru"],
"n_id": [12, 112],
"phone": [77777777, 3377777777]}