Skip to content

Commit

Permalink
Update storage.py
Browse files Browse the repository at this point in the history
  • Loading branch information
TheExplainthis committed Mar 23, 2023
1 parent 4b9d73a commit 5732645
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/storage.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import json
import datetime


class FileStorage:
Expand All @@ -20,12 +21,14 @@ def __init__(self, db):
self.db = db

def save(self, data):
user_id, api_key = data.items()
self.db['api_key'].update_one({
'user_id': data.get('user_id')
'user_id': user_id
}, {
'$set': {
'user_id': data.get('user_id'),
'api_key': data.get('api_key'),
'user_id': user_id,
'api_key': api_key,
'created_at': datetime.datetime.utcnow()
}
}, upsert=True)

Expand Down

0 comments on commit 5732645

Please sign in to comment.