-
Type: Improvement
-
Resolution: Done
-
Priority: Minor - P4
-
Affects Version/s: 2.2.1
-
Component/s: Public API
-
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`.
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`.