mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-04 18:31:13 -05:00
Add api_token model and dao
This commit is contained in:
17
app/dao/api_tokens_dao.py
Normal file
17
app/dao/api_tokens_dao.py
Normal file
@@ -0,0 +1,17 @@
|
||||
from app import db
|
||||
from app.models import ApiToken
|
||||
|
||||
|
||||
def save_token_model(token, update_dict={}):
|
||||
if update_dict:
|
||||
del update_dict['id']
|
||||
db.session.query(ApiToken).filter_by(id=token.id).update(update_dict)
|
||||
else:
|
||||
db.session.add(token)
|
||||
db.session.commit()
|
||||
|
||||
|
||||
def get_model_api_tokens(token=None):
|
||||
if token:
|
||||
return ApiToken.query.filter_by(token=token).one()
|
||||
return ApiToken.query.filter_by().all()
|
||||
Reference in New Issue
Block a user