Uploaded image for project: 'Mongoid'
  1. Mongoid
  2. MONGOID-4592

Support the :local_default or :store_default option to fields, which defines a default value for document fields without persisting that value to the database

      this allows us to define a field like field :local_default, type: Boolean, default: true, local_default: true, which then doesn't persist the "default" value when saving the document unless the the value is not the default. This helps cut down our document sizes when we still want sane defaults locally.

      Note that this affects ETL: because ETL reads directly from Mongo, these defaults will no longer be available in that context, and will therefore be nil. For this reason you should be careful when using :local_default on fields, and ensure the ETL code is modified appropriately if a downstream client requires a field to have a default value.

        1. field_with_local_default (1).rb
          2 kB
          Matthew Monteleone

            Assignee:
            oleg.pudeyev@mongodb.com Oleg Pudeyev (Inactive)
            Reporter:
            matthew.monteleone@mongodb.com Matthew Monteleone
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: