beanie icon indicating copy to clipboard operation
beanie copied to clipboard

[BUG]before_event bug

Open CAPITAINMARVEL opened this issue 11 months ago • 3 comments

class Sample(Document): num: int name: str version: int = 0

@before_event(Update)
def increase_version(self):
    self.version += 1

doc = await Sample.find_one() await doc.inc({Sample.num: 1})

i looked in database num increase so its clearly updated but the versioning is never changing

CAPITAINMARVEL avatar Mar 25 '24 15:03 CAPITAINMARVEL

its because in update it only update with args from the query itself but the action event doesnt it it

CAPITAINMARVEL avatar Mar 25 '24 20:03 CAPITAINMARVEL

Hi @CAPITAINMARVEL , Unfortunately it would be tricky and not explicit enough to add an addition set step to the update query for this case

roman-right avatar Apr 16 '24 23:04 roman-right

This issue is stale because it has been open 30 days with no activity.

github-actions[bot] avatar May 17 '24 02:05 github-actions[bot]

This issue was closed because it has been stalled for 14 days with no activity.

github-actions[bot] avatar May 31 '24 02:05 github-actions[bot]