- 云开发数据库取子集的前N条?
[ { "_id": "1f154439638e97330137f2475dec9ffc", "title": "1", "remarks": [ { "remarktime": "2022/12/06 14:13:12", "id": 1670307282722 }, { "remarktime": "2022/12/06 13:00:10", "id": 1670302838410 }, { "remarktime": "2022/12/06 12:58:19", "id": 1670302752430 }, { "remarktime": "2022/12/06 12:49:31", "id": 1670302182764 }, { "remarktime": "2022/12/06 12:49:09", "id": 1670302197960 }, { "id": 1670298287375, "remarktime": "2022/12/06 11:43:50" } ] }, { ... } ] 只想取得remarks的前三个怎么做?
2022-12-06 - for循环总是再if之后才执行?
//临时图地址换cloud地址 getCloudPath(path) { let result = 0 wx.cloud.uploadFile({ cloudPath: 'image/' + new Date().getTime() + "_" + Math.floor(Math.random() * 1000) + ".jpg", filePath: path, success: res => { console.log("upload success", res.fileID) result = res.fileID }, fail: res => { result = 0 } }) return result }, that.editorCtx.getContents({ success(res) { wx.showLoading({ title: '发布中...', }) var html = res.html if (res.text.trim()=="") { wx.hideLoading() that.setData({ showOneButtonDialog: true, test_content1: '请添加文章内容' }) } else { //临时图片地址更换云地址 --that.getCloudPath函数时利用临时地址换云存储地址 for (var i = 0; i < that.data.imagelist_local.length; i++) { if (html.indexOf(that.data.imagelist_local[i]) >= 0) { let cloudpath = that.getCloudPath(that.data.imagelist_local[i]) html.replace(that.data.imagelist_local[i], cloudpath) } } if(that.data.programid==''){//新发布 db.collection('Program').add({ data: { title: e.detail.value.title, html: html, content: res.text, datetime: util.formatTime(new Date()), creater: app.globalData.csridinfo.StaffName, id: that.data.index, }, success: (res) => { wx.showToast({ title: '发布成功', }) }, fail: (res) => { wx.showToast({ title: '发布失败', icon: 'error' }) } }) }else{//修改 db.collection('Program').doc(that.data.programid) .update({ data:{ title: e.detail.value.title, html: html, content: res.text, datetime: util.formatTime(new Date()), id: that.data.index, },success:(res)=>{ wx.showToast({ title: '发布成功', }) },fail:(res)=>{ wx.showToast({ title: '发布失败', icon: 'error' }) } }) } } } })
2022-12-01 - 如何将子集合提到上层?
//查询语句 db.collection('ProgramOfPerson').aggregate() .match(_.and([{ _openid: '*' }, { like: 1 }])) .project({ programid: 1 }) .lookup({ from: 'Program', let: { id: '$programid' }, pipeline: $.pipeline() .match(_.expr($.and([ $.eq(['$_id', '$$id']), ]))) .project({ _id:0, title: 1, datetime: 1, content: $.substrCP(['$content', 0, 100]) }) .done(), as: 'a' }) .end() [{ "_id": "*", "programid": "*", "a": [ { "datetime": "2022/11/22 12:33:26", "title": "24", "content": "24\n" } ] }] 将上面的转为下面的 [{ "_id": "*", "programid": "*", "datetime": "2022/11/22 12:33:26", "title": "24", "content": "24\n" }]
2022-11-29 - 小程序发布审核是否有明确的标准?
同样的代码前一天还能审核通过,只是修改了一些bug和优化体验,今天有一直审核不通过,那么既然之前能够通过审核,表示我的代码基本符合规范,那么现在又不通过是什么意思?并且一天之内两次提交两次审核的问题还不一样?希望官方能够明确具体的审核流程,毕竟有时候更新小程序是为了尽快修复BUG,那么这样一直拖着或者由于不一样的审核规范,将直接导致小程序无法正常使用,这样对用户和开发者,运营人员来说都是不好的,希望审核的流程可以优化一下!!!
2021-09-16 - 文档链接没了,weui 文档指向GitHub?
https://developers.weixin.qq.com/miniprogram/dev/platform-capabilities/extended/weui/
2021-09-13 - weui组件库的说明文档为什么没有了?
https://developers.weixin.qq.com/miniprogram/dev/platform-capabilities/extended/component-plus/
2021-09-02 - 使用Collection.watch监听时发现,对于返回的更新完整记录doc的排序问题?
let that = this; db.collection('TemporaryFiling') .orderBy('Date', 'desc') .where({ value:'1' }) .watch({ onChange:function(snapshot){ that.setData({ TemporaryFiling:snapshot.docs }) console.log("snapshot1",snapshot) }, onError:function(snapshot){ console.log("snapshot2",snapshot) } }) 像这样的 返回的snapshot.docs并没有完全按照orderby中进行排序,原有的记录按规定排序了,我这里是按照添加的时间倒序排序,但是新增加的记录每次都是在记录的最后一条,并不是按排序规则在第一条,希望大家能帮我找一下问题在哪,谢谢
2021-08-23 - 在云函数中使用lookup联表查询,对右表做限制,限制条件以参数形式传入,但是却无法得到传入的参数?
//云函数 exports.main = async (event, context) => { return await db.collection('Staff').aggregate() .match({ GroupID:event.id }) .lookup({ from: 'EpidemicRegistration', let: { ccsrid: '$CSRID', aDate:event.today }, pipeline: $.pipeline() .match(_.expr($.and([ $.eq(['$CSRID', '$$ccsrid']), $.eq(['$Date', '$$aDate']), $.eq(['$Type','0']) ]))) .project({ _id: 0, ApproveState: 1, Type: 1 }) .done(), as: 'ER' }) .end() } //小程序调用 wx.cloud.callFunction({ name:'getApproveList', match:{ id:'236', today:'2021-08-16' } }) 想法是在调用时传入两个参数(id,today)分别给云函数中(aDate:event.today)(GroupID:event.id),多次尝试后发现id可以接收到,但是在lookup 中let里面始终无法得到传入的参数,想问下通过什么方式可以将参数传入let中
2021-08-17