- 云数据库查询时可以查找一个数组字段的长度是否大于0么?
云数据库查询时可以查找一个数组字段的长度是否大于0么?
2021-04-07 - 用cloud base console去模拟调用云函数一直报错?
今天用cloud base console去模拟调用云函数一直报错。之前都没有问题。 { "errorCode": -1, "errorMessage": "Runtime.UserCodeSyntaxError: SyntaxError: Unexpected identifier\n at Object.module.exports.load (/var/runtime/node10/UserFunction.js:33:13)\n at Runtime.handleOnce (/var/runtime/node10/Runtime.engine.js:95:38)\n at Timeout.setTimeout [as _onTimeout] (/var/runtime/node10/Runtime.engine.js:54:12)\n at ontimeout (timers.js:436:11)\n at tryOnTimeout (timers.js:300:5)\n at listOnTimeout (timers.js:263:5)\n at Timer.processTimers (timers.js:223:10)", "statusCode": 443 } [图片]
2021-02-08 - Watcher一直报socket handshake失败的错误?
之前Watcher一直都是正常使用的,今天开始一直报这个错误, 这个错误现每次都会出。 VM16 asdebug.js:1 WebSocket connection to 'wss://tcb-ws.tencentcloudapi.com/' failed: Error during WebSocket handshake: Unexpected response code: 502 createSocketTask @ VM16 asdebug.js:1 invoke @ VM16 asdebug.js:1 r @ VM16 asdebug.js:1 invoke @ VM1255 WAService.js:2 o @ VM1255 WAService.js:2 (anonymous) @ VM1255 WAService.js:2 p @ VM1255 WAService.js:2 t @ VM1255 WAService.js:2 n @ VM1255 WAService.js:2 connectSocket @ VM1255 WAService.js:2 (anonymous) @ VM1255 WAService.js:2 (anonymous) @ VM1255 WAService.js:2 (anonymous) @ VM1255 WAService.js:2 (anonymous) @ VM1255 WAService.js:2 (anonymous) @ VM1255 WAService.js:2 (anonymous) @ VM1255 WAService.js:2 n @ VM1255 WAService.js:2 index.js? [sm]:399 the watch closed because of error Error: errCode: -402011 realtime listener unexpected fatal error | errMsg: [object Object] history states: UNINIT-(close)->CLOSED at new g (VM1255 WAService.js:2) at _i.closeWithError (VM1255 WAService.js:2) at _parentFSMListener (VM1255 WAService.js:2) at VM1255 WAService.js:2 at Set.forEach (<anonymous>) at Do.transition (VM1255 WAService.js:2) at Function.<anonymous> (VM1255 WAService.js:2) at C (VM1255 WAService.js:2) at VM1255 WAService.js:2 at VM1255 WAService.js:2 onError @ index.js? [sm]:399 (anonymous) @ VM1255 WAService.js:2 C @ VM1255 WAService.js:2 (anonymous) @ VM1255 WAService.js:2 c @ VM1255 WAService.js:2 (anonymous) @ VM1255 WAService.js:2 C @ VM1255 WAService.js:2 (anonymous) @ VM1255 WAService.js:2 _i.closeWithError @ VM1255 WAService.js:2 _parentFSMListener @ VM1255 WAService.js:2 (anonymous) @ VM1255 WAService.js:2 Do.transition @ VM1255 WAService.js:2 (anonymous) @ VM1255 WAService.js:2 C @ VM1255 WAService.js:2 (anonymous) @ VM1255 WAService.js:2 (anonymous) @ VM1255 WAService.js:2 value @ VM1255 WAService.js:2 (anonymous) @ VM1255 WAService.js:2 (anonymous) @ VM1255 WAService.js:2 c @ VM16 asdebug.js:1 (anonymous) @ VM16 asdebug.js:1 i.emit @ VM16 asdebug.js:1 S.onclose @ VM16 asdebug.js:1 VM1255 WAService.js:2 Error: MiniProgramError {"errMsg":"closeSocket:fail task not found"} at Object.errorReport (VM1255 WAService.js:2) at Function.thirdErrorReport (VM1255 WAService.js:2) at Object.<anonymous> (VM1255 WAService.js:2) at I (VM1255 WAService.js:2) at Object.o [as cb] (VM1255 WAService.js:2) at VM1255 WAService.js:2 at Array.forEach (<anonymous>) at e.value (VM1255 WAService.js:2) at o (VM1255 WAService.js:2) at VM1255 WAService.js:2 errorReport @ VM1255 WAService.js:2 thirdErrorReport @ VM1255 WAService.js:2 (anonymous) @ VM1255 WAService.js:2 I @ VM1255 WAService.js:2 o @ VM1255 WAService.js:2 (anonymous) @ VM1255 WAService.js:2 value @ VM1255 WAService.js:2 o @ VM1255 WAService.js:2 (anonymous) @ VM1255 WAService.js:2 VM1255 WAService.js:2 TypeError: n is not a function at Oi.<anonymous> (VM1255 WAService.js:2) at VM1255 WAService.js:2 at Object.next (VM1255 WAService.js:2) at n (VM1255 WAService.js:2)
2021-02-07 - 请问Cloudbase会支持类似MongoDB ContinueOnError的功能么?
我在云函数往云数据库插入数据的时候,一次插入多条,并且通过设置_id来保证数据的唯一性。但是Cloudbase没有提供类似ContinueOnError的功能,每次有重复的_id就直接报错,整个任务都失败了。什么时候能提供一个类似MongoDB ContinueOnError都功能,如果部分数据发生插入失败,不影响其他数据的插入。
2021-01-12 - 云函数调用数据库报错,请教报错信息的含义?
我在一个云函数里有大量的数据要插入,由于插入数据库时有request body大小的限制,所以我做了一个循环让数据能够分批插入,但是每次云函数都报错,不太明白报错信息都含义。 const MAXPAYLOAD = 2000000; let pList = []; let totalSize = JSON.stringify(vals).length; if (totalSize < MAXPAYLOAD) { pList.push(db.collection("testCollection").add({ data:vals })); } else { let percent = Math.floor(MAXPAYLOAD/totalSize*100); let i = 0; while (i < vals.length) { var batchSize = Math.floor(vals.length*percent/100); var tempList = vals.slice(i, batchSize); var checkLength = JSON.stringify(tempList).length; while (checkLength > MAXPAYLOAD) { batchSize = Math.floor(batchSize * percent / 100); tempList = vals.slice(i, batchSize); checkLength = JSON.stringify(tempList).length; } tempList = vals.slice(i, batchSize); i += batchSize; console.log(batchSize); pList.push(db.collection("testCollenction").add({ data:tempList })); } } console.log(pList.length); let res = await Promise.all(pList); 报错信息如下: [图片]
2021-01-08 - 请问在云函数通过db.collection().add()方法向数据库插入数据最大支持多少的大小?
我在云数据库插入数据时遇到了下面这个错误,请问这个Payload的limit时多少啊?我可以在插入之前可以做一个检查,适当减小插入的数量。 当时我传入参数转成字符串的话大概是15384201个字符。 [图片]
2021-01-08 - 微信小程序有办法创建一个进程,在页面切换的时候一直在后台运行?
我现在能想到的是通过云函数来做,但是如果在某个页面调用了云函数,如果页面被切换了,云函数会终止么? 或者小程序SDK是否提供这样的接口来实现运行在后台的进程?
2021-01-07 - 可以将在TCB Console申请的云环境用于小程序的开发么?
我在TCB Console申请了云环境,但是我发现没有配置可以和小程序相连。如果小程序想用云开发,云环境只能在IDE里面申请。请问有没有办法在小程序端连接在TCB Console里申请的云环境或者云数据库?
2020-12-24 - 云数据库更新的时候是否可以一次更新多条数据,每条数据更新的字段不固定?
这个问题背后的场景是,我们想和外部数据库做一下同步,当我获取到外部数据之后,想直接一次性更新这些数据。 比如是否支持这样来更新数据 exports.main = async (event, context) => { const wxContext = cloud.getWXContext() cloud.init({env: event.env}); let db = cloud.database({env: event.env}); const _ = db.command return await db.collection('book').where({ name: _.in(['book30','book31']) }).update([{data:[{name:"book30", sold:10},{name:"book31", sold:5}]}); } 从文档来看好像如果要更新多条数据的话,只能更新这些数据中的固定字段。但是同步的时候我这边无法确切知道会有哪些字段会更新。 希望云数据库能够支持类似外键的功能,可以在数据中设置这些外键,然后可以批量更新数据 比如: update({data:[{externalId:"key1",data:""},{externalId:"key2",data:""}]})
2020-11-03