def update_entries(self, _id, vals):
"""Update entries in the Entries_Table
Args:
_id(ObjectId): ObjectID of the entry you want to change
vals(collection): New values
Return:
result(bool):True if the update was successful. False if it fails
"""
entries_table = self.db["Entries_Table"]
try:
vals["Last_Modified"] = datetime.now()
if not entries_table.find_one({"_id": ObjectId(_id)}):
return False
entries_table.update_one({"_id": ObjectId(_id)},
{"$set": vals})
return True
except errors.ServerSelectionTimeoutError:
print('ERROR : No connection could be made because'
' the target machine actively refused it')
return False
评论列表
文章目录