Announcement Announcement Module
No announcement yet.
Spring MongoDB -- How can I alter schema at runtime? Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Spring MongoDB -- How can I alter schema at runtime?

    Hello ,

    I am working on a POC where in we are thinking of using MongoDB and Spring MongoDB to interact with it. One of the requirement of the POC is that we should be available to add fields to a document which I think is a reasonable requirement as MongoDB is schema-less
    datatstore. But when we work with Spring MongoDB we will be first designing our entity class which will be mapped to a document . So
    are we lossing schemaless feature of MongoDB ? Can anybody suggest better ways using Spring MongoDB to cater to changing


  • #2
    Can anybody reply?

    Can anybody reply?


    • #3
      Schemaless means that the store does not impose a schema on your data model but that rather the data model is the schema. With a relational store you have to define a schema for the database and then map your classes onto it. With NoSQL the domain model pretty much becomes the schema and the store doesn't get in the way just because you add a new property to a class maybe.

      If you really need to be very flexible you can still store a Map<String, Object> into MongoDB and you'll get complete flexibility within this map while still being able to define indexes on particular keys.

      PS: Please be a bit patient waiting for answers to your question. Bumping the post will rather let people refrain from answering. Thanks!