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接口' –