Reputation: 3896
I know Mongo is more subjective to way of working (please don't shut this thread because of that) but is there a performance or 'best practive' way for Mongo on to store out of these two ways:-
Option1 - all switches in one document, every document with fields:-
{
"stuffA": 415125,
"booleanSwitchA": true,
"booleanSwitchB": false,
"booleanSwitchC": true,
}
or
Option2 - multiple documents with one field switch - collated in app:-
{
"stuffA": 415125,
"switch": "a",
}
{
"stuffA": 415125,
"switch": "b",
}
{
"stuffA": 415125,
"switch": "c",
}
Upvotes: 0
Views: 78
Reputation: 4550
I think the option depends how you want to use it. If you have to query to load all the information in one query based on the stuffA , then option one is best option , but if you have to query each switch individually , option two will go . Even I think one of possible design can also be , because you can index the array elements also.
{
"stuffA": 415125,
"OnSwitch" : {"A" , "C"},
"OffSwitch" : {"C"}
}
Upvotes: 3