mirror of
https://github.com/simple-login/app.git
synced 2025-09-15 02:54:53 +08:00
add flush option to ModelMixin.create()
This commit is contained in:
parent
ba3074b94a
commit
0055ca976b
1 changed files with 5 additions and 0 deletions
|
@ -83,12 +83,17 @@ class ModelMixin(object):
|
|||
def create(cls, **kw):
|
||||
# whether should call db.session.commit
|
||||
commit = kw.pop("commit", False)
|
||||
flush = kw.pop("flush", False)
|
||||
|
||||
r = cls(**kw)
|
||||
db.session.add(r)
|
||||
|
||||
if commit:
|
||||
db.session.commit()
|
||||
|
||||
if flush:
|
||||
db.session.flush()
|
||||
|
||||
return r
|
||||
|
||||
def save(self):
|
||||
|
|
Loading…
Add table
Reference in a new issue