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

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

    • Type: Icon: New Feature New Feature
    • Resolution: Unresolved
    • Priority: Icon: Unknown Unknown
    • None
    • Affects Version/s: None
    • Component/s: Dev Exp
    • 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 Unassigned
            Reporter:
            shields@tablecheck.com Johnny Shields
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: