python - How to set TTL index for collection in MongoKit? -


i want use 'time live' collection feature (http://docs.mongodb.org/manual/tutorial/expire-data/) in app (flask+mongokit).

it possible create ttl index documents in collection via mongokit when describe models or need use pymongo instead?

thanks

you can use pymongo layer create ttl index documents:

http://api.mongodb.org/python/current/api/pymongo/collection.html#pymongo.collection.collection.ensure_index

exemple assuming have user mongokit model:

db.user.collection.ensure_index("name", 300) 

note ttl deprecated in pymongo 2.3. use cache_for instead.


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -