小程序数据库操作会有Promise风格的回调,备注一下回调写法给新人
db.collection('userInfo').where({
_openid: _.eq(openid)
}).count()
.then(res => {
console.log(res.total);
}).catch(res => {
console.log(res);
})
count()请求的结果是Promise风格,要用then->catch接收
本文介绍小程序中使用Promise风格进行数据库操作的方法,通过示例展示如何使用count()方法统计数据库集合中符合条件的记录数量,并处理其回调结果。
小程序数据库操作会有Promise风格的回调,备注一下回调写法给新人
db.collection('userInfo').where({
_openid: _.eq(openid)
}).count()
.then(res => {
console.log(res.total);
}).catch(res => {
console.log(res);
})
count()请求的结果是Promise风格,要用then->catch接收
1414
854
512
914

被折叠的 条评论
为什么被折叠?