Flask-PyMongo collMod

前端 未结 2 967
北海茫月
北海茫月 2021-01-25 06:37

I\'m trying to update a TTL collection with the PyMongo. Trying to run this I get \'failed no such cmd: index\'

client.db.command({\'collMod\': url,
                     


        
2条回答
  •  栀梦
    栀梦 (楼主)
    2021-01-25 06:59

    Well I've just decided to switch my index around to instead set the time I want the document to expire at in the database instead of saying how long I want the document to live by using

    db.test.ensure_index("expireOn", expireAfterSeconds=0)
    

    Now I can set the field to a future time that I want the entry to expire instead of having to change the index. Seems strange that as of now there is no way to update the index programatically using python.

提交回复
热议问题