Skip to content

flask-softdeletes 基于flask-sqlalchemy的软删除实现

Notifications You must be signed in to change notification settings

kanhebei/flask-softdeletes

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

flask-softdeletes

介绍

flask-softdeletes 基于flask-sqlalchemy的软删除实现

使用简介

1.安装

pip install flask-softdeletes

2.导入 SoftDeletedMixin

from flask_softdeletes import SoftDeletedMixin

3.模型类继承 SoftDeletedMixin

class DemoModel(SoftDeletedMixin, db.Model):pass

4.使用查询

[查询正常的数据,不包含已被软删除数据]
DemoModel.query

[只查询已经被软删除的数据]
DemoModel.query.only_trashed

[查询所有的数据, 包括已被软删除的和没有被软删除的数据]
DemoModel.query.with_trashed

[软删除数据]

demo = DemoModel.query.get(1)

demo.delete()

[恢复软删除的数据]

demo = DemoModel.query.with_trashed.get(1)

demo.restore()

About

flask-softdeletes 基于flask-sqlalchemy的软删除实现

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages