- 关于_inc(值) 数据库自增 这个里面的值不能用变量吗?
关于_inc(值) 数据库自增 这个里面的值不能用变量吗? js: check(){ const dc = db.command db.collection('ruku').where({ goods_name:this.data.goodList, store:this.data.storeList }).get().then(res=>{ console.log(res) db.collection('ruku').doc(res.data[0]._id).update({ data:{ goods_num:dc.inc(this.data.count) }, }).then(ress=>{ console.log(ress) }) }) }, 控制台:Error: errCode: -502001 database request fail | errMsg: [FailedOperation] multiple write errors: [{write errors: [{Cannot increment with non-numeric argument: {goods_num: "15325"}}]}, {<nil>}] at new t (WASubContext.js?t=wechat&s=1650450834060&v=2.14.1:17) at Function.success (WASubContext.js?t=wechat&s=1650450834060&v=2.14.1:17) at d (WASubContext.js?t=wechat&s=1650450834060&v=2.14.1:2) at Object.success (WASubContext.js?t=wechat&s=1650450834060&v=2.14.1:2) at r (WASubContext.js?t=wechat&s=1650450834060&v=2.14.1:26) at WASubContext.js?t=wechat&s=1650450834060&v=2.14.1:26 at b (WASubContext.js?t=wechat&s=1650450834060&v=2.14.1:26) at WASubContext.js?t=wechat&s=1650450834060&v=2.14.1:26 at WAServiceMainContext.js:11 at VM9 asdebug.js:1(env: Windows,mp,1.05.2203251; lib: 2.14.1)
2022-04-20 - 求大佬解答啊啊啊啊?
//wxml {{item.name}} 删除 创建仓库 //JS Page({ /** * 页面的初始数据 */ data: { title:null, store_name:null, storeList:[], num:null, total:null, beachTimes:null, }, //获取仓库信息 getStoreList(){ const max_num = 20; db.collection('store').count().then(res=>{ console.log(res) this.setData({ total:res.total, }) this.setData({ beachTimes:Math.ceil(this.data.total/20) }) console.log(this.data.beachTimes) console.log(this.data.total) var list = []; for(let j = 0;j{ console.log(rez) for(let i = 0;i [图片] 问题已解决感谢各位大佬: wxml: <!--显示现有仓库--> <scroll-view scroll-y="true" class="showStore" style="height: 1000rpx;"> <block wx:for="{{storeList}}" wx:key="index"> <view class="name">{{item.store_name}}</view> <view class="delete" data-id="{{item._id}}" bindtap="delStore">删除</view> </block> </scroll-view> <!--提交表单--> <form action="submit" bindsubmit="createStore"> <input type="text" name="storename" placeholder="请输入仓库名称"/> <button class="createSt" bindtap="flashPage" type="primary" form-type="submit" >创建仓库</button> </form> JS: //获取仓库信息 getStoreList(){ const max_num = 20; db.collection('store').count().then(res=>{ console.log(res) this.setData({ total:res.total, }) this.setData({ beachTimes:Math.ceil(this.data.total/20) }) console.log(this.data.beachTimes) console.log(this.data.total) var list = [] var olddata = [] for(let j = 0;j<this.data.beachTimes;j++){ db.collection('store').skip(j*max_num).limit(max_num).get().then(ress=>{ olddata=ress.data list = olddata.concat(list) console.log(list) this.setData({ storeList:list }) }) } }) console.log('storeList是',this.data.storeList) }, 控制台: [图片]
2022-04-01 - 想问下大佬们 云函数"创建集合" 集合名称能从 form 组件里的Input 传入嘛?
云函数: const cloud = require('wx-server-sdk') cloud.init({ env: "aaaa-a" }) // 云函数入口函数 const db = cloud.database() exports.main = async (event, context) => { const wxContext = cloud.getWXContext() return await db.createCollection('a') //就是这个里面参数能不能从前面的页面获取从而自定义这个集合名称? }
2022-03-10