Description Usage Arguments Details Value See Also Examples
Add a time to live (TTL) index to a collection
1 | mongo.index.TTLcreate(mongo, ns, key, expireAfterSeconds, index_name = NULL)
|
mongo |
(mongo) A mongo connection object. |
ns |
(string) The namespace of the collection to add a TTL index to. |
key |
(mongo.bson) The desired field(s) to use as the basis for expiration time. The field should be of type 'Date'. Alternately, Alternately, |
expireAfterSeconds |
(Numeric or Integer) The time in seconds after which records should be removed. |
index_name |
(string) The name of the index to be created. |
See http://docs.mongodb.org/manual/tutorial/expire-data.
NULL if the command failed. mongo.get.err()
may be
MONGO_COMMAND_FAILED.
(mongo.bson) The server's response if successful.
1 2 3 4 5 6 7 8 9 | mongo <- mongo.create()
if (mongo.is.connected(mongo)) {
for (i in 1:10) mongo.insert(mongo, ns = 'test.testTTL', b = list(a = i, last_updated = i))
res_bson <- mongo.index.TTLcreate (mongo, ns = 'test.testTTL', key = list(last_updated = 1),
expireAfterSeconds = 3600, index_name = 'last_updated_1')
print(res_bson);
mongo.drop(mongo, ns = 'test.testTTL')
}
mongo.destroy(mongo);
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.