0

I have the following problem:
I want to create a document with a settings subdocument.
These settings can be updated later and filled with "real" values.
Should the settings that are left empty at creation, be filled with an empty string:

"settings": {
        "logo": "",
        "background": "",
        "color": "",
        "active": false
    },

filled with null:

"settings": {
        "logo": null,
        "background": null,
        "color": null,
        "active": false
    },

or completely left out:

"settings": {
        "active": false
    },
UrinUwe
  • 13
  • 2
  • when we have a value(even if null) the index can be used and be fast, for example if you are looking for `color=null` , also you can see the schema.But this doesn't mean that this is always better, maybe there are more criteria that i am missing, but those 2 are in favour of `null` – Takis Dec 16 '21 at 20:59
  • @Takis_ yes, I just saw [this](https://stackoverflow.com/questions/13256912/mongodb-documents-empty-value-or-omit-pair-altogether) post which is almost the same problem. Thanks for your fast reply. – UrinUwe Dec 16 '21 at 23:27

0 Answers0