I have a question about the general guidance of how to properly mongodb design:
Scenario: I have many collection of objects, all uniquely identified by their contract_address, and i want to be able to pull from there when need be. I found this post, but it didn't seem like enough reasoning.
so would it make sense to have each document have structure A or structure A
structure A - objects of objects
{
"name": "Peter".
"all_nfts": {
"0x202": {...},
"0x342": {...},
...
}
or
structure B - array of objects
{
"name": "Peter".
"all_nfts": [
{"contract_address" : "0x202", ...},
{"contract_address" : "0x340", ...},
...
]
I would think that structure A would make the most sense because you can just index into the all_nfts field to find the the object corresponding to it, instead of searching through an array which could be O(n) time instead O(1). I was told structure B was better by other experienced MongoDB devs but I don't understand why.
I was told structure B was better by other experienced MongoDB devs but I don't understand why. How do you map option A on the client side?