我正在尝试使用 PyMongo 更新 TTL 集合。试图运行这个我得到“失败没有这样的命令:索引”
client.db.command({'collMod': url,
'index': {'keyPattern': {'dateCreated':1},
'expireAfterSeconds': 3600}})
有人能指出我做错了什么吗?
我相信这会起作用,假设url
包含带有您正在修改的索引的集合的名称:
client.db.command('collMod', url,
index={'keyPattern': {'dateCreated':1},
'expireAfterSeconds': 3600}})
对于其他正在寻找解决方案的人,我通过以下方法进行了管理:
client.db.command('collMod', 'notifications',
index={'keyPattern': {'expr': 1},
'background': True,
'expireAfterSeconds': 604800})
这会产生以下输出:
{u'expireAfterSeconds_old': 3888000,
u'expireAfterSeconds_new': 604800, u'ok': 1.0}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)