个人案例
店小two
一个方便老板管理店铺,方便会员消费的小程序
店小two扫码体验
- Aggregate 聚合分页查询操作时 .count()会改变输出结果?
首先,我想实现一个分页查询统计的功能,需要获取总条数和查询数据。 谁能告诉我为什么我 .count() 后,输出的 list 为啥变成了 [{total: 10}] ,我很不理解?????!!! const aggregateInstance = db.collection('deal').aggregate().sort({ createTime: -1 }).lookup({ from: 'users', localField: '_userId', foreignField: '_id', as: 'userInfo', }).lookup({ from: 'stores', localField: '_storeId', foreignField: '_id', as: 'storeInfo', }).lookup({ from: 'users', localField: '_operatorId', foreignField: '_id', as: 'operatorInfo', }).match({ 'userInfo.nickName': db.RegExp({ regexp: '.*' + keyword, options: 'i', }) }) const totalResult = await aggregateInstance.count('total').end() console.log(totalResult); // {list:[{total: 24}], errMsg: "collection.aggregate:ok"} const total = totalResult.list[0] && totalResult.list[0].total const {list} = await aggregateInstance.skip((pageIndex - 1) * pageSize).limit(pageSize).end() console.log(list); // [{total: 24}] [图片]
2022-08-01 - 微信开发者工具终端打不开?
[图片] 我的vscode就可以打开终端,微信开发工具怎么也打不开,有遇到这种问题的小伙伴吗?
2022-01-29