how can i apply filter on related column when using update method #1157
-
i have a TableA that has a foreign key to TableB and i want to use |
Beta Was this translation helpful? Give feedback.
Answered by
dantownsend
Feb 28, 2025
Replies: 1 comment
-
Here's an example you can run in await Band.update({Band.popularity: Band.popularity + 5}).where(Band.manager.name == 'Guido') Which is for the following schema: from piccolo.table import Table
from piccolo.columns import ForeignKey, Integer, Varchar
class Manager(Table):
name = Varchar(length=100)
class Band(Table):
name = Varchar(length=100)
manager = ForeignKey(references=Manager)
popularity = Integer() |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
dantownsend
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Here's an example you can run in
piccolo playground run
:Which is for the following schema: