mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
Add commentary on ttl index
This commit is contained in:
parent
05e390ef89
commit
a17040f00f
2 changed files with 12 additions and 0 deletions
|
@ -2,3 +2,13 @@ notifications-sharelatex
|
|||
===============
|
||||
|
||||
An API for managing user notifications in ShareLaTeX
|
||||
|
||||
|
||||
database indexes
|
||||
================
|
||||
|
||||
For notification expiry to work, a ttl index on `notifications.expiresFrom` must be created:
|
||||
|
||||
```javascript
|
||||
db.notifications.createIndex({expiresFrom: 1}, {expireAfterSeconds: (60*60*24*30)})
|
||||
```
|
||||
|
|
|
@ -29,6 +29,8 @@ module.exports =
|
|||
templateKey: notification.templateKey
|
||||
expires: notification.expires || false
|
||||
# ttl index on `expiresFrom` field
|
||||
# in Mongo, TTL indexes only work on date fields,
|
||||
# and ignore the document when that field is missing
|
||||
if doc.expires
|
||||
doc.expiresFrom = new Date()
|
||||
db.notifications.insert(doc, callback)
|
||||
|
|
Loading…
Reference in a new issue