- aggregate match时使用操作符是无效的
https://developers.weixin.qq.com/miniprogram/dev/wxcloud/reference-sdk-api/database/aggregate/Aggregate.match.html 文档最后那行实际输出的结果是7,而不是3,说明aggregate match时使用操作符_.gt是无效的,等同没有此条件,实际返回所有数据。 [代码]{ [代码][代码]"_id"[代码] [代码]: [代码][代码]"1"[代码][代码], [代码][代码]"author"[代码] [代码]: [代码][代码]"stark"[代码][代码], [代码][代码]"score"[代码] [代码]: 80 }[代码][代码]{ [代码][代码]"_id"[代码] [代码]: [代码][代码]"2"[代码][代码], [代码][代码]"author"[代码] [代码]: [代码][代码]"stark"[代码][代码], [代码][代码]"score"[代码] [代码]: 85 }[代码][代码]{ [代码][代码]"_id"[代码] [代码]: [代码][代码]"3"[代码][代码], [代码][代码]"author"[代码] [代码]: [代码][代码]"bob"[代码][代码], [代码][代码]"score"[代码] [代码]: 60 }[代码][代码]{ [代码][代码]"_id"[代码] [代码]: [代码][代码]"4"[代码][代码], [代码][代码]"author"[代码] [代码]: [代码][代码]"li"[代码][代码], [代码][代码]"score"[代码] [代码]: 55 }[代码][代码]{ [代码][代码]"_id"[代码] [代码]: [代码][代码]"5"[代码][代码], [代码][代码]"author"[代码] [代码]: [代码][代码]"jimmy"[代码][代码], [代码][代码]"score"[代码] [代码]: 60 }[代码][代码]{ [代码][代码]"_id"[代码] [代码]: [代码][代码]"6"[代码][代码], [代码][代码]"author"[代码] [代码]: [代码][代码]"li"[代码][代码], [代码][代码]"score"[代码] [代码]: 94 }[代码][代码]{ [代码][代码]"_id"[代码] [代码]: [代码][代码]"7"[代码][代码], [代码][代码]"author"[代码] [代码]: [代码][代码]"justan"[代码][代码], [代码][代码]"score"[代码] [代码]: 95 }[代码][代码]const db = wx.cloud.database()[代码][代码]const _ = db.command[代码][代码]const $ = _.aggregate[代码] [代码]db.collection([代码][代码]'article'[代码][代码])[代码][代码] [代码][代码].aggregate()[代码][代码] [代码][代码].match({[代码][代码] [代码][代码]score: _.gt(80)[代码][代码] [代码][代码]})[代码][代码] [代码][代码].group({[代码][代码] [代码][代码]_id: [代码][代码]null[代码][代码],[代码][代码] [代码][代码]count: $.sum(1)[代码][代码] [代码][代码]})[代码][代码] [代码][代码].end()[代码]预期结果: [代码]{ [代码][代码]"_id"[代码] [代码]: [代码][代码]null[代码][代码], [代码][代码]"count"[代码] [代码]: 3 }[代码]实际结果: [代码]{ [代码][代码]"_id"[代码] [代码]: [代码][代码]null[代码][代码], [代码][代码]"count"[代码] [代码]: 7 }[代码]
2019-11-29 - 发现微信小程序开发时无法正常引入第三方JS库
发现微信小程序开发时无法正常引入第三方JS库,分析了后发现,微信小程序无法正常执行类似如下js代码: [代码]( [代码][代码]function[代码] [代码](self) {[代码][代码] [代码][代码]'use strict'[代码][代码];[代码][代码] [代码][代码]console.log([代码][代码]'*** self in fetch.js: '[代码][代码], self)[代码][代码] [代码][代码]if[代码] [代码](self.fetch) {[代码][代码] [代码][代码]return[代码][代码] [代码][代码]}[代码][代码]})([代码][代码]this[代码][代码]);[代码]出错信息如下: [代码]*** self in fetch.js: undefined[代码] [代码]index.js? [sm]:6 Uncaught TypeError: Cannot read property 'fetch' of undefined[代码] [代码] [代码][代码]at index.js? [sm]:6[代码][代码] [代码][代码]at index.js? [sm]:3[代码][代码] [代码][代码]at require (WAService.js:9)[代码][代码] [代码][代码]at appservice:55[代码]显然,并没有把 this 赋值给 self 不知要如何处理,才能让第三方JS库中有类似如上代码的库能正常引入到微信小程序的JS文件代码中。
2017-11-02