for update
This commit is contained in:
parent
52f45beaec
commit
6c7d6bb6b0
3 changed files with 9 additions and 4 deletions
|
|
@ -75,10 +75,13 @@ class Item(db.Model):
|
|||
self.meta = {}
|
||||
|
||||
@classmethod
|
||||
def get(cls, id):
|
||||
def get(cls, id, for_update=False):
|
||||
if isinstance(id, list):
|
||||
id = base64.b32encode(hashlib.sha1(''.join(id)).digest())
|
||||
return cls.query.filter_by(id=id).first()
|
||||
qs = cls.query.filter_by(id=id)
|
||||
if for_update:
|
||||
qs = qs.with_for_update()
|
||||
return qs.first()
|
||||
|
||||
@classmethod
|
||||
def get_or_create(cls, id, info=None):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue