database.aggregate is longer than 3s?
发布于 5 年前 作者 yshi 15323 次浏览 来自 官方Issues

云函数代码如下:

const cloud = require(‘wx-server-sdk’)

cloud.init({

 env: ‘egyptmanagement-8a2de’

})

const db = cloud.database()

const _ = db.command

const $ = db.command.aggregate

// 云函数入口函数

exports.main = async(event, context) => {

 //var cmd = event.cmd;

 console.log(event);

 db.collection(‘eat’).aggregate().group({

   _id: {

     address: ‘$address’,

     date: ‘$date’,

     type: ‘$type’

   },

   tsum: $.sum(’$number’)

 }).end().then(res => {

   console.log(“结果:”,res)

   return res

 })

 return null

}

eat collection里面有5条数据.

number是整形,非字符串

调用查看日志成功, 但是确始终没有数据返回, 报个这样的信息.

Database operation database.aggregate is longer than 3s. Please check query performance and your network environment.

1 回复

超时了。改成await

回到顶部