On Wed, 31 Jul 2013, sarvesh gupta wrote:
> I am using Mongo 2.4.5 and writing code using C# driver.
>
> I found that we can we only set expiry time at collection level. As
> per my use case, I require to set a different ttl for individual
> document.
As the TTL expiry happens on a check for a specific field's date/time,
plus the ttl that is set in the index, you can of course precalculate
the field's date value... so you could just add the TTL to the field's
value, and set a TTL of 0:
Instead of:
TTL: dateValue = 60;
{
_id: 42;
dateValue: new ISODate( "2013-07-31 15:10:41" );
}
You can do:
TTL: dateValue = 0;
{
_id: 42;
dateValue: new ISODate( "2013-07-31 15:11:41" );
}
I.e. = add the 60 to the `dateValue` field. With this, you can then add
different ttls for each document yourself.
cheers,
Derick
--
{
website: [ "
http://mongodb.org", "
http://derickrethans.nl" ],
twitter: [ "@derickr", "@mongodb" ]
}