Uploaded image for project: 'Ruby Driver'
  1. Ruby Driver
  2. RUBY-1083

Support "expire_after_seconds" in addition to "expire_after" in index view

    • Type: Icon: Improvement Improvement
    • Resolution: Done
    • Priority: Icon: Minor - P4 Minor - P4
    • 2.3.0
    • Affects Version/s: 2.2.1
    • Component/s: Public API
    • Labels:
    • Major Change

      Right now in the index view there's a mapping that maps expire_after to expireAfterSeconds.
      ( https://github.com/mongodb/mongo-ruby-driver/blob/b61d29c2f9b2c62cab5345c550f51b2b216d925c/lib/mongo/index/view.rb#L53 )

      This means that to create an index that uses a ttl for a collection, you need to set the expire_after option, e.g.:

      ```
      .collection.indexes.create_one(
      {:time => 1},
      {:expire_after => 86400}
      )
      ```

      This is inconsistent with the other mappings that are just `.underscore`-ed versions of the MongoDB params.

      To make things more confusing, in Mongoid, this mapping is reversed with another mapping, so there the value is `expire_after_seconds`.

      ( https://github.com/mongodb/mongoid/blob/9fca9c254afbb38a0ead1d6133edea683f63ba35/lib/mongoid/indexable/specification.rb#L14 )

      And finally the `expire_after_seconds` or `expireAfterSeconds` option is silently dropped when creating an index, causing potentially enormous database growth.

      In order to keep things consistent across the database, ruby driver and Mongoid, it would be better to rename `expire_after` to `expire_after_seconds`.

            Assignee:
            emily.stolfo Emily Stolfo
            Reporter:
            robert@appsignal.com Robert Beekman
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: