This is my code:
timestamp = datetime.datetime.now()
mongo.db.user.ensure_index("createAt", expireAfterSeconds=180)
mongo.db.user.insert_one({'username':json['username'],'password':json['password'],"createAt": timestamp})
This above way deletes all the documents in the collection after 3 mins. I want to delete the specific user after 3 mins based on "createAt".
Ex:
{ "_id" : ObjectId("5b73f30a7d1312555a4ea629"), "username" : "hanson01@gmail.com", "password" : "111111", "createAt" : ISODate("2018-08-15T09:30:00.066Z") }
{ "_id" : ObjectId("5b73f30a7d131255asdasdas"), "username" : "hanson02@gmail.com", "password" : "111111", "createAt" : ISODate("2018-08-15T09:31:00.066Z") }
The account with username hanson01@gmail.com will be deleted before hanson02@gmail.com
Does anyone have any ideas? Thank you.