Is it common to use single document collections for schema validation?

Hello there,

I have a set of containers that need to store settings in mongodb. Each container has a schema for their settings. I want to verify that users can only adjust the settings of a service in accordance with its schema.

My plan is to store the settings of each container in a separate collection and use the schema validation feature to enforce it. However means that each collection will only contain one document (the settings document).

Is this a common practice when storing settings in mongodb? Is it OK to have single document collections when using schema validation?

Hi @Maher_Sallam ,

Well using collections for a single document sounds like an antipattern we call to.many collections if you are thinking on having large number of schemas like that.

What I think you should consider is using a module or some existing client side enforce to validate a specific object validation for this single object. You can store the schema object that is used to validate in MongoDB per “setting”

Let me know if that makes sense to you.