Shortcut chainable methods for Criteria persistence context - read_mode(), write_concern(), etc.

XMLWordPrintableJSON

    • Type: New Feature
    • Resolution: Unresolved
    • Priority: Unknown
    • None
    • Affects Version/s: None
    • Component/s: Dev Exp
    • None
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      MongoDB has a nested param structure for readPreference and writeConcern. This also is required when using Criteria#with() method:

      MyModel.with(read: { mode: :primary })
      MyModel.with(write: { w: :majority, j: 1, wtimeout: 10 })

      This syntax awkward. It would be nicer if we could just do:

      MyModel.read_mode(:primary)      # or read_preference()
             .write_concern(:majority) # or write_w(), write_ack()
             .write_journal(1)
             .write_timeout(10)

      Also as args to with() method:

      MyModel.with(read_mode: :primary, write_concern: :majority, ...)

      There is some concern (pun intended) that these names could be used by MongoDB server parameters in the future, but I think it's pretty unlikely and there is already some precedent for flat-usage of these parameters in MongoDB Connection String URIs

              Assignee:
              Unassigned
              Reporter:
              Johnny Shields
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated: