exports.main = async (event, context) => {\n const db = cloud.database();\n const yddata = db.collection('yddata');\n const pageSize = 1000; // 定义每页显示的数据数量\n const startIndex = 0; // 定义起始索引值\n let query = yddata.where({});\n\n if (event.mailNumber) {\n query = query.where({ mailNumber: event.mailNumber });\n }\n \n if (event.startDate && event.endDate) {\n query = query.where({\n date: db.command.gte(event.startDate).and(db.command.lte(event.endDate))\n });\n }\n\n const searchData = await query.orderBy('date', 'desc').skip(startIndex).limit(pageSize).get().then(res => {\n if (res.data.length > 0) {\n const data = res.data[0];\n return {\n searchData: data,\n images: data.images,\n describe: data.describe,\n date: data.date\n };\n } else {\n return {\n error: '未找到相关数据'\n };\n }\n }).catch(err => {\n console.error(err);\n return {\n error: err\n };\n });\n return searchData;\n}

云函数实现邮件号/时间区间查询 - 返回查询结果内容

原文地址: https://www.cveoy.top/t/topic/pTHN 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录