|< < 43 > >|

MongoDB Data Model

Dynamic Schema

Comments from Company A

We'll typically have a multistep process where we restructure our application model to have optional fields for the new values (perhaps with a default when null for when reading older document formats), and then opportunistically update our database to the new format whenever documents are subsequently stored.

However, we also have some admin-level jobs we can manually trigger which iterate over all documents in a collection just to read each document and then save it based on the last-known application format. This force updates all documents in the collection. We don't do this often because it can be time consuming depending on the size of the collection, and most of the time it isn't necessary. [MongoDB was supposed to save you from this!]

The upside to running a job like that, though, is that we can then clean up the application code to remove default values and/or make optional values (if optional strictly for the purpose of the progressive model update) required as appropriate.

|< < 43 > >|