小程序云开发中数据库数据倒序排列
1、首先,在添加数据的时候添加个时间字段。data: { title: this.data.title, content: this.data.content, tag: this.data.tag, xx:0, oo:0, createTime:db.serverDate() //添加该字段 }
2、然后拉取数据的时候,云函数使用orderby进行排序exports.main 屏顿幂垂= async (event, context像粜杵泳) => {try { return await db.collection('dbtest').orderBy('createTime','desc').get();} catch (e) { console.error(e);}}
声明:本网站引用、摘录或转载内容仅供网站访问者交流或参考,不代表本站立场,如存在版权或非法内容,请联系站长删除,联系邮箱:site.kefu@qq.com。
阅读量:69
阅读量:81
阅读量:75
阅读量:79
阅读量:79