I'm trying to store configuration in MongoDB. I want the document schema to be dynamic so as to store different type of configuration in the collection. The configuration may consist of more than just simple string key-value pairs. While using spring-data-mongodb, I see that I need to define a class which is usually mapped to a mongodb. So, when I need to add more configuration to the collection, I need to make changes to the class. I don't really want to do this as I want to be able to modify configuration without code changes (and ideally without restarting long-running applications). Also, what I'm eventually storing is configuration which should be consumed by different services, so I can't really have a well-defined schema. Instead, I would want the services to pull configuration from the store (i.e. provide key, get value). This makes me doubt where spring-data-mongodb is the right choice for such a use-case. Is there any obvious solution or alternative to my use-case?
Thanks in advance.
The obvious solution is use just the Java driver for MongoDB. The Java driver has an implementation of BSON's spec and you can work with BSON/JSON objects instead classes.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With