def upsert_user(username: str, password: str=None, scope: dict=None):
filter = {'username': username}
set = {}
if password is not None:
set['password_hash'] = generate_password_hash(password)
if scope is not None:
set['scope'] = UserJWT.validate_scope(scope)
return UsersCollection().find_one_and_update(filter, {'$set': set}, {'_id': False, 'password_hash': False},
return_document=ReturnDocument.AFTER, upsert=True)
评论列表
文章目录