- 云开发聚合排序结果问题?
数据库集合:sp,数据内容如下: [ { "_id": "86012367-54b9-4dab-b4bd-d213ef9fe81b", "lx": 0, "dt": "2020-03-07T03:09:36.390Z", "cap": "国家体育局" }, { "_id": "981cc2f0-ad33-4275-bb1b-051faddd15bb", "dt": "2020-03-07T03:04:29.929Z", "cap": "国家要求", "lx": 0 }, { "_id": "491de141-a7e9-49a5-95af-0b0ae3928992", "lx": 1, "dt": "2020-03-07T03:11:15.142Z", "cap": "单杠" }, { "_id": "1c856c60-b126-4984-8c86-e6288adae733", "cap": "太极推手", "lx": 1, "dt": "2020-03-07T03:10:47.703Z" }, { "_id": "2a9cde70-ca73-4b2e-ab03-13252fb854e3", "cap": "儿童秋千", "lx": 1, "dt": "2020-03-07T02:39:09.084Z" }, { "_id": "0aed39ac-49df-4616-a1b5-bf54835151f5", "cap": "跑步机", "lx": 1, "dt": "2020-03-07T02:36:14.685Z" } ] 代码操作内容:云函数对数据进行聚合排序返回结果,两种方式:云端调用和本地调用,但排序结果不一致。调用结果和代码如下 云端调用的结果不正确,但如果将云端代码中sortdata参数内容直接写死到云函数代码中,执行结果是正确的。 [图片] [图片] [图片] 调用代码: getdatasortcloud("sp",{},{lx:1,dt:-1},0).then(res=>{ console.log('cloud',res) }) 模块函数 module.exports.getdatasortcloud = function getdatasortcloud(tablename, sqldata, sortdata, pagenum) { if (pagenum < 0) { pagenum = 0 } return new Promise((resolve, reject) => { wx.cloud.callFunction( { name: "getdatasort", data: { tablename: tablename, sqldata: sqldata, sortdata: sortdata, pagenum: pagenum }, success: res => { resolve(res.result.data) }, fail: err => { reject() } } ) } ) } 云函数getdatasort代码: exports.main = async (event, context) => { const db = cloud.database() const tablename=event.tablename const sqldata=event.sqldata const sortdata=event.sortdata const pagenum=event.pagenum var data=[] try{ let rs=await db.collection(tablename).aggregate().match( sqldata ).sort( sortdata ).skip(pagenum*100).limit(100).end() data=rs.list }catch(e){} return { data:data, } }
2020-03-07 - 新建云开发项目时,项目目录名称问题?
开发者工具开发版本的最新版本和回退版本:新建小程序云开发项目,指定目录名称为sport,建立好项目后,无法找到首页,换个目录名称就可以,不知道大家能复现这个问题不? [图片] [图片]
2020-03-01 - 小程序调用地址解析服务出错?
wx.serviceMarket.invokeService({ service: "wx30a496aefcb662cc", api: "geoc", data: { address: "山西省阳泉市矿区四矿小区" }, }).then(res=>{ console.log(res) }).catch(err=>{ console.log(err) }) 提示错误: Error: invokeService:fail operateWXData:fail (err_code -7) 请教大神错误在哪里?我已经在服务平台上购买了免费的服务了,也授权了。
2020-02-25 - 小程序调用地址解析代码问题?
const bs = await wx.serviceMarket.invokeService({ service: 'wx30a496aefcb66233', api: 'geoc', address: '山西省阳泉市矿区四矿小区' }) console.log('invokeService success', bs) VM492:1 file: default/default.js unknown: await is a reserved word (95:15) 93 | 94 | > 95 | const bs = await wx.serviceMarket.invokeService({ | ^ 96 | service: 'wx30a496aefcb66c88', 97 | api: 'geoc', 98 | address: '山西省阳泉市矿区四矿小区' console.error @ VM492:1 (anonymous) @ VM522:2 VM498 WAService.js:2 Page "default/default" has not been registered yet.
2020-02-24