Comments (2)
@JoshYuJump You have 2 ways to delete a record.
- As a query builder with delete method
@router.delete('/product/{row_id}')
async def delete_product(row_id: str):
await Product.delete().where(Product.id == row_id)
- As an ORM with objects
@router.delete('/product/{row_id}')
async def delete_product(row_id: str):
product = await Product.objects().where(Product.id == row_id).first()
# you can also use get() method like this to get single object
# product = await Product.objects().get(Product.id == row_id)
await product.remove() # a proxy to a delete query
Hope that helps.
from piccolo.
@sinisaos Thanks a lot, It was so helpful to me.
from piccolo.
Related Issues (20)
- Fix `load_json` on joined tables
- Support arrays of timestamp / timestamptz / date / time in SQLite
- cockroachDB extremely long query due to Array(UUID()) HOT 3
- Upgrade CockroachDB
- Is there a way to truncate the table? HOT 3
- Add support for `CAST` to convert between types
- Add more operators to `QueryString`
- Add basic math functions
- Improve array serialisation in `get_sql_value`
- Replace deprecated `@abstractproperty`
- Add `not_any` method to `Array`
- Add `Concat` function
- Replace deprecated `startup` and `shutdown` events in asgi templates HOT 1
- Document how to achieve a `OneToOneField` in Piccolo
- Use `TableTest` to cut down boiler plate in tests
- Be able to hardcode migrations as fake
- Reverse relations fetching HOT 11
- Fix typo in `Email` docstring
- Improve `LazyTableReference`
- Add `Album` table to playground
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from piccolo.