'Post and Delete vs. Post and Patch for Model's BooleanField?
I'm using Postgres. I've seen threads comparing DELETE and INSERT vs. UPDATE but my use case is slightly different:
I want to allow users to "check" and "uncheck" an Item model to be true or false with the default state being false.
Does it make more sense to:
1) Post and Delete
Create a CheckedItem model (with a ForeignKey to the Item) when they check.
Delete that object when they uncheck. If a CheckedItem does not exist, its Item is unchecked.
2) Post and Patch
Create a CheckedItem model (with a ForeignKey to the Item) with a check BooleanField as true when they check.
Patch the BooleanField to false when they uncheck. If a CheckedItem does not exist or has a false check field, its Item is unchecked.
If it matters, there's two other ForeignKeys I would have on every CheckedItem - one for the user and one for the ItemParent.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
