uniapp排序文档地址
我自己写了一个小程序测试排序,
结果返回和期望不一样
'use strict';
exports.main = async (event, context) => {
var param = {};
const db = uniCloud.database();
const collection = db.collection("t_sys_config2");
let query = collection.where({});
query = query.orderBy("order2", "asc");
query = query.orderBy("order1", "asc");
let res = await query.get();
res.query = query;
console.log("数据库查询结果:" + JSON.stringify(res));
return null;
};
方式2:颠倒了order2和order1顺序
'use strict';
exports.main = async (event, context) => {
var param = {};
const db = uniCloud.database();
const collection = db.collection("t_sys_config2");
let query = collection.where({});
query = query.orderBy("order1", "asc");
query = query.orderBy("order2", "asc");
let res = await query.get();
res.query = query;
console.log("数据库查询结果:" + JSON.stringify(res));
return null;
};
执行结果如下图;
注意,我再res返回结果里面拼接了query对象,