Closed Angusross111 closed 1 year ago
hi @Angusross111
maxExpiry option is working when creating a collection, check the code below to set the expiry time at the model level:
const schema = new Schema({
name: String,
});
const collectionName = 'maxExpiryCollection';
const MaxExpiryModel = model<{ name: string }>(collectionName, schema, { maxExpiry: 5 });
Note: In this example maxExpiry (in seconds) will be used as an option to create the collection, therefore all documents in this collection will be removed after the maxExpiry
value.
@Angusross111
Yes, It's possible to set individual expiry/TTL: Model functions:
Model.create
Model.createMany
Model.replaceById
Model.updateById
Model.findOneAndUpdate
Document functions:
Document.save
I'm checking it, due to it's not working currently.
In the next version, we will release a fix to it.
Hi @Angusross111
These changes were released in version 2.3.2
I have tried using the
maxExpiry
option onModel.create
,Model.updateById
,CreateModelOptions
when creating the model as well as some of the other places. None seem to work, every document going into my collection still have theremeta.expiration
set to 0. Is it possible to set individual documents with an expiry/TTL ? The collection was created with the maxExpiry as 0.