微信云开发官网
如题
[图片] 以上是云函数里面的源码 下面是云函数本地调试报错,res结果出来了并且能够将data里面的数据点出来,但是后面再用的话会报这个错 reason: Error: errCode: -1 unknown error | errMsg: parameter.data should be object instead of undefined; [图片][图片]
[图片]
in 只能验证单个字段,如果多个字段都使用in,数据不一样
[图片]意思是如果不是用云开发支付的订单就查不到吗?
我想吧腾讯云开发迁移到阿里上去, 有一个云函数用了 cloud.openapi.subscribeMessage.send 这个方法 然后阿里云开发里执行就会报错 Error: errCode: -501007 invalid parameters | errMsg: collection.count:fail missing secretId or secretKey of tencent cloud; at collection.count api; 有什么办法去配置这个id和key吗? 还是只能改成 http的接口写法?
[图片] 用了几周cms,早上还迁移了几个数据库,过了一段时间打算新建一个模型的时候,竟然无法访问了!首先我的网络没问题,后来我又切换成移动流量开热点也无法访问,不知道怎么回事
[图片] [图片] [图片] [图片] Promise.then()在云函数说没有定义,是要引用哪个文件吗?
我尝试使用Aggregate.sort对聚会结果进行排序,先看数据格式,如下图: (month是标准时间,phoneNumber是字符串) [图片] 我的代码是这样的: exports.main = async (event, context) => { const { date, department } = event, match = { class: '薪酬' }; if (date) { const start = new Date(date.start.time), end = new Date(date.end.time); match.month = _.and(_.gt(start), _.lt(end)) } if (department.department1 != '全部') match.department1 = department.department1; if (department.department2 != '全部') match.department2 = department.department2; // 查询并返回 const get = await db.collection('salary').aggregate() .match(match) .group({ _id: { month: '$month', department1: '$department1', department2: '$department2', name: '$name', phoneNumber: '$phoneNumber', paidInAmount: '$paidInAmount' } }) .sort({ phoneNumber: -1, }) .limit(1000) .end(); return get }; 结果,无论是对时间格式的字段(month),还是字符串格式的字段(phoneNumber),进行排序都不生效,输出如下: 即不能实现按时间先后顺序排序,或按字符串排序。 [图片] 请教各位大佬,我的代码哪里写错了?感谢
类似getShareInfo 这种, 返回一个cloudID 。 这样我们解密activityid 也方便, 不然的话,解密不能借助云开发,还得自己维护session_key ,本身session_key 的获取也不支持云调用。 不知道authPrivateMessage 为什么不给cloudID 是有其他考量吗?
[图片]
[图片] 这里应该怎么改比较合适
这里是想实现聊天功能,所以有一个ChatOnline集合来保存用户是否在线 ChatOnline集合里只有一条数据,user1是1813100并且user2是18121300的数据 [图片] 当我用开发工具登录18131000的账号,用多账号测试或者真机登录18121300账号的时候,18131000退出时返回正常,但18121300用户退出时数据库查询函数查出的数据如图,和实际数据库的内容不符 [图片] onUnload: function () { var that = this const uid = wx.getStorageSync('uid') const info = wx.getStorageSync('info') db.collection('ChatOnline') //更新自己的在线状态 .where(db.command.or([ { user1:info.id, user2:uid, }, { user1:uid, user2:info.id }, ])) .get() .then(res=>{ console.log(res.data) //这里返回的数据错误 if(res.data[0].user1=info.id) { console.log("use1") db.collection('ChatOnline') //更新自己的状态 .where({ user1:info.id, user2:uid }).update({ data:{ user1online:false } }).then(res=>{ console.log('退出') }) } else{ console.log("use2") db.collection('ChatOnline') //更新自己的状态 .where({ user2:info.id, user1:uid }).update({ data:{ user2online:false } }).then(res=>{ console.log('退出') }) } }) } [图片]
[图片]写了个接口调用但是不知道add这里面的条件要怎么写才能添加成功
https://developers.weixin.qq.com/miniprogram/dev/wxcloud/guide/extensions/cms/introduction.htmlhttps://developers.weixin.qq.com/miniprogram/dev/wxcloud/guide/extensions/cms/introduction.html [图片][图片] Markdown编辑器无法使用
wx.getWeRunData({ success (res) { // 拿 encryptedData 到开发者后台解密开放数据 const encryptedData = res.encryptedData // 或拿 cloudID 通过云调用直接获取开放数据 const cloudID = res.cloudID } }) 类似获取 getWeRunData ? 得到cloudID 。 https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/share/private-message.html [图片] wx.authPrivateMessage({ shareTicket: object.shareTicket, success(res) { console.log('authPrivateMessage success', res); //没有这个cloudID ???? }, fail(res) { console.log('authPrivateMessage fail', res) } }) authPrivateMessage 试过,得不到这个CloudID .
各位大佬,本人初学者,在学习编写一个投票小程序,在投票页面调用云函数时分为匿名和实名,匿名调用正常,但是在实名的时候就报错:Error: cloud.callFunction:fail Error: errCode: -504002 functions execute fail | errMsg: Error: docId必须为字符串或数字,发现实名投票调用云函数时候Postdata中的VoteID传过去了,但是经过console.log(res.result)打印却为空,请大佬指点为何? 云函数: const cloud = require('wx-server-sdk') cloud.init() const db=cloud.database() // 云函数入口函数 exports.main = async (event, context) => { const wxContext = cloud.getWXContext() const openid=wxContext.OPENID const {pickedOption,userInfo,voteID}=event.postData const voteItem=userInfo?{ openid, pickedOption, userInfo }:{ openid, pickedOption } return await db.collection('vote').doc(voteID).update({ data:{ voteList:db.command.push(voteItem) } }) } 本地调用: onTapVote(){ if (this.data.isAnonymous){ const postData={ voteID:this.data.voteID, pickedOption:this.data.pickedOption } wx.cloud.callFunction({ name:'vote', data:{ postData } }).then(res=>{ console.log(res.result) this.getVoteStatusFromServer(this.data.VoteID) }).catch(res=>{ console.error(res) wx.showToast({ title: '匿名投票失败', icon:'none' }) }) }else { const _this=this wx.getUserProfile({ desc: '正在获取', success(res){ const postData = { VoteID:_this.data.voteID, userInfo:res.userInfo, pickedOption:_this.data.pickedOption } wx.cloud.callFunction({ name:'vote', data:{ postData } }).then(res=>{ console.log(res.result) }).catch(res=>{ console.error(res) wx.showToast({ title: '实名投票失败', icon:'none' }) }) //_this.getVoteStatusFromServer(_this.data.VoteID) }, fail(res){console.log(res)}, }) } },
const cloud = require('wx-server-sdk') cloud.init({ env: "cloud1-2geukr2red49cb1b" }) const xlsx = require('node-xlsx'); exports.main = async (event, context) => { try { let dataCVS = '单.xlsx' let s={alignmen:{ horizontal:"center", vertical:"center", wrapText:true, } }; let data = [ [{v:'起重机维修保养派工单',s}], ]; const sheetOptions = {'!merges': [{s: {c: 0, r: 0}, e: {c: 3, r: 0}},{s: {c: 1, r: 2}, e: {c: 3, r: 2}},{s: {c: 1, r: 3}, e: {c: 3, r: 3}},{s: {c: 0, r: 4}, e: {c: 0, r: 12}},{s: {c: 1, r: 4}, e: {c: 3, r: 12}},{s: {c: 0, r: 15}, e: {c:0, r: 16}},{s: {c: 1, r: 15}, e: {c:3, r: 16}},{s: {c: 0, r: 18}, e: {c: 0, r: 20}},{s: {c: 1, r: 18}, e: {c: 1, r: 20}},{s: {c: 2, r: 18}, e: {c: 2, r: 20}},{s: {c: 3, r: 18}, e: {c: 3, r: 20}},{s: {c: 1, r: 21}, e: {c: 3, r: 21}},{s: {c: 1, r: 22}, e: {c: 3, r: 22}},{s: {c: 1, r: 23}, e: {c: 3, r: 23}}],'!cols': [{wch: 18}, {wch: 18}, {wch: 18}, {wch: 18}]}; var buffer = await xlsx.build([{name: 'mySheetName', data: data}], {sheetOptions}); return await cloud.uploadFile({ cloudPath: dataCVS, fileContent: buffer, }) } catch (e) {} console.error(e) return e } [图片]
在云函数中支持调用Collection.watch来进行监听云数据库中的变化吗?
db.collection(collection).get().then(res => { }). catch (error => { log.setFilterMsg('dbase_error_getdata') log.info(JSON.stringify(error)) }) 小程序基础库2.17 ,wx6442a03024212ff0, 上述语句在小程序端调用,不是在云端。 在小程序实时日志当中有大量错误日志,错误日志现在主要分为两种, 一种是打印出来是空的,就是这个error是空的 另外一种就是{"errMsg":"operateWXData:fail:cgi fail(2,-1)","operateWXDataFail":true} 这到底是什么原因产生的日志,论坛搜了半天也查不到有用的信息,我看到贴子说不用管它!希望官方能给个答复
小程序示例
小程序官方示例Demo,包含云开发示例。
小程序示例
扫码体验