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

Add phantom custom field type example

    • Type: Icon: Improvement Improvement
    • Resolution: Fixed
    • Priority: Icon: Unknown Unknown
    • 7.4.1
    • Affects Version/s: None
    • Component/s: Docs
    • Fully Compatible

      The custom fields documentation (https://www.mongodb.com/docs/mongoid/master/reference/fields/#custom-field-types) currently only gives an example of a "real" field, where the value being stored is of the declared type.

      Another use case of custom field types is a "phantom" one, where the field type defines mongoize/demongoize/evolve methods that convert from one type of value to another, and neither of these value types is the instance of the field type class itself. For example, this can be used to implement enums where the set of values in the application is different (e.g. more verbose/descriptive) than the set of values in the database.

            Assignee:
            oleg.pudeyev@mongodb.com Oleg Pudeyev (Inactive)
            Reporter:
            oleg.pudeyev@mongodb.com Oleg Pudeyev (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: