zzl00770

导航

getskiplimit 跳过指定条数的数据 ,常用于分页

//云端代码
'use strict';
const db = uniCloud.database()
exports.main = async (event, context) => {
    const collection = db.collection(event.name)
    const res = await collection.where(event.data).limit(event.limit).get()
    return res
};
//前端代码
getskiplimit() {
    uni.showLoading({
        title: '处理中...'
    })
    uniCloud.callFunction({
        name: 'getskiplimit',
        data:{
            name:'unicloud-test',
            data:{
                product:"uniCloud2"
            },
            skip:1,//跳过指定数量的数据
            limit:2//返回的结果集(文档数量)
        }
    }).then((res) => {
        uni.hideLoading()
        uni.showModal({
            content: `查询成功,获取数据列表为:${JSON.stringify(res.result.data)}`,
            showCancel: false
        })
        console.log(res)
    }).catch((err) => {
        uni.hideLoading()
        uni.showModal({
            content: `查询失败,错误信息为:${err.message}`,
            showCancel: false
        })
        console.error(err)
    })
},

 

posted on 2024-01-26 21:43  品味人生nuiapp  阅读(3)  评论(0编辑  收藏  举报