add flush option to ModelMixin.create()
This commit is contained in:
parent
ba3074b94a
commit
0055ca976b
|
@ -83,12 +83,17 @@ class ModelMixin(object):
|
||||||
def create(cls, **kw):
|
def create(cls, **kw):
|
||||||
# whether should call db.session.commit
|
# whether should call db.session.commit
|
||||||
commit = kw.pop("commit", False)
|
commit = kw.pop("commit", False)
|
||||||
|
flush = kw.pop("flush", False)
|
||||||
|
|
||||||
r = cls(**kw)
|
r = cls(**kw)
|
||||||
db.session.add(r)
|
db.session.add(r)
|
||||||
|
|
||||||
if commit:
|
if commit:
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
|
|
||||||
|
if flush:
|
||||||
|
db.session.flush()
|
||||||
|
|
||||||
return r
|
return r
|
||||||
|
|
||||||
def save(self):
|
def save(self):
|
||||||
|
|
Loading…
Reference in a new issue