db.temp.ensure_index("createdAt",expireAfterSeconds=3*60)
timestamp = datetime.utcnow()
for i in l:
i["createdAt"] = timestamp
i['table'] = 1
db.temp.insert_one(i)
In the above code, expireAfterSeconds
is working only if it specifies as 3*60
.
I am getting error if I change its value. I need to set the expiration time for 10
minutes
Error: raise OperationFailure(errmsg, code, response, max_wire_version) pymongo.errors.OperationFailure: Index with name: createdAt_1 already exists with different options, full error: {'operationTime': Timestamp(1632732176, 1), 'ok': 0.0, 'errmsg': 'Index with name: createdAt_1 already exists with different options', 'code': 85, 'codeName': 'IndexOptionsConflict', '$clusterTime': {'clusterTime': Timestamp(1632732176, 1), 'signature': {'hash': b"\xb4\xaf\xaa\xb7\x1e\xd4:\xa4\xf7\x81\xa8\xa9\xef\xa1}\xa7\x8e('i", 'keyId': 6961454804933541890}}}