0
我想确保我的收藏使用the ming ODM mapper过期超过2周以上的文档:如何使用Ming设置TTL索引?
class SloData(MappedClass):
class __mongometa__:
session = session
name = 'slo_data'
indexes = ['application']
custom_indexes = [
# expire records after two weeks
dict(fields=('datetime',), expireAfterSeconds=14*24*60*60)
]
_id = FieldProperty(schema.ObjectId)
datetime = FieldProperty(schema.DateTime)
value = FieldProperty(str)
application = RelationProperty('SloApplication')
def ensure_indexes():
for mapper in ming.odm.Mapper.all_mappers():
session.ensure_indexes(mapper.collection)
但是,当我把收集和再保证索引,expireAfterSeconds指数未设置:
{
"v" : 1,
"key" : {
"datetime" : 1
},
"ns" : "performance.slo_data",
"name" : "datetime_1",
"background" : true,
"sparse" : false
}
谢谢,我会给它一个镜头。 –
我无法将'db'看作'session'的属性,你确定你有这个权利吗? –
我在'session.impl.db.collection_name'中找到了pymongo接口' –