Skip to main content

基于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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

Flask-SoftDeletes-1.0.2.tar.gz (2.5 kB view hashes)

Uploaded Source

Built Distribution

Flask_SoftDeletes-1.0.2-py3-none-any.whl (3.1 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page