有时候需要进行复杂的查询,但是仅仅靠QuerySet提供的那些方法是完全不够的,tortoise-orm提供了Q对象,用于做复杂的查询

 

from tortoise.query_utils import Q

Sanic二十七:Sanic + tortoise-orm 之Q对象

Sanic二十七:Sanic + tortoise-orm 之Q对象

 

1、与:&

Sanic二十七:Sanic + tortoise-orm 之Q对象

Sanic二十七:Sanic + tortoise-orm 之Q对象

若不写连接符,则默认为and

Sanic二十七:Sanic + tortoise-orm 之Q对象

Sanic二十七:Sanic + tortoise-orm 之Q对象

 

2、或:|

Sanic二十七:Sanic + tortoise-orm 之Q对象

Sanic二十七:Sanic + tortoise-orm 之Q对象

 

3、非:~

Sanic二十七:Sanic + tortoise-orm 之Q对象

Sanic二十七:Sanic + tortoise-orm 之Q对象

 

相关文章:

  • 2021-10-06
  • 2021-06-07
  • 2021-10-17
  • 2022-12-23
  • 2021-12-06
  • 2022-01-31
  • 2022-01-10
  • 2021-11-27
猜你喜欢
  • 2021-11-22
  • 2021-07-12
  • 2021-08-18
  • 2021-12-13
  • 2021-07-30
  • 2022-01-12
  • 2021-05-22
相关资源
相似解决方案