array(2) { ["docs"]=> array(0) { } ["count"]=> int(0) } 111string(0) "" int(1) int(10) int(70) int(8640000) string(13) "likecs_art_db" array(1) { ["query"]=> array(1) { ["match_all"]=> object(stdClass)#28 (0) { } } } array(1) { ["createtime.keyword"]=> array(1) { ["order"]=> string(4) "desc" } } int(10) int(0) int(8640000) array(2) { ["docs"]=> array(0) { } ["count"]=> int(0) } orm查询基本操作 - 爱码网

 

orm  ----关系对象模型

orm 的查询两种操作

1.基于对象的查询

oneTo one

一对多

和多对多

对象.关联字段

对象.表名(_set))

2.基于QUERYset的查询

双下划线即为跨表查询操作

 

3.基本操作

1.结果是对象的

get();first();last()

条件如果是多个会报错=

2.结果是Queryset的

filter();values(),value_list();all();annote();exclude(),distinct();order_by();reverse()

注意

order_by('-id','age')先按照id降序然后再按age升序
3.功能相关

exists();count()

4.聚合和分组
aggregate(average_price=Avg('price'))

annotate(author_num=Count("author"))

 

4.过滤条件:

 lt gt in contains  icontains  isnull   rangestartswith,istartswith, endswith, iendswith,regex,data,year month,weekday   hour minute second

 

相关文章: