Add phantom custom field type example

XMLWordPrintableJSON

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

      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 (Inactive)
            Reporter:
            Oleg Pudeyev (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: