数据库结构如下:
{"_id":"17e","XM":"张三","SX":"3","ZH":[{"JC":"11","SX":"1"}]}
{"_id":"171","XM":"王五","SX":"1","ZH":[{"JC":"22","SX":"2"},{"JC":"11","SX":"1"}]}
{"_id":"5b3","XM":"李四","SX":"2","ZH":[{"JC":"11","SX":"9"},{"JC":"22","SX":"2"},{"JC":"33","SX":"4"}]}
想查询的结果:
一、首先按照SX(第一个)对记录升序排序
二、然后,每一个记录中,ZH字段内的对象,按照ZH.SX升序
这个,能用orderBy实现吗?
里面也要排序需要用聚合查询
.orderBy('SX', 'asc') .orderBy('ZH.SX', 'asc')
试试这个行不行了。