基于flask-sqlalchemy的软删除实现
Project description
# flask-softdeletes
## 介绍 flask-softdeletes 基于flask-sqlalchemy的软删除实现
## 使用简介
### 1.安装 <code>pip install flask-softdeletes</code>
### 2.导入 SoftDeletedMixin
<code>from flask_softdeletes import SoftDeletedMixin</code>
### 3.模型类继承 SoftDeletedMixin
<code>class DemoModel(SoftDeletedMixin, db.Model):pass</code>
### 4.使用查询
[查询正常的数据,不包含已被软删除数据] <code> DemoModel.query</code>
[只查询已经被软删除的数据] <code> DemoModel.query.only_trashed</code>
[查询所有的数据, 包括已被软删除的和没有被软删除的数据] <code> DemoModel.query.with_trashed</code>
[软删除数据]
<code> demo = DemoModel.query.get(1)</code>
<code> demo.delete() </code>
[恢复软删除的数据]
<code> demo = DemoModel.query.with_trashed.get(1)</code>
<code> demo.restore() </code>
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for Flask_SoftDeletes-1.0.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 177ed8e856f7c874fb4d0720941ef09a68b83930d8c7aec933688981a3aa46c3 |
|
MD5 | 83703705504e0c021fbabbf86fd5f798 |
|
BLAKE2b-256 | f73820540d6eb68574cbde797b607ef0f4c6e4cf0479b518245c935840352eba |