收藏
回答

database.aggregate is longer than 3s?

云函数代码如下:

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.

最后一次编辑于  11-26
回答关注问题邀请回答
收藏

1 个回答

  • 老张
    老张
    11-26

    超时了。改成await

    11-26
    赞同
    回复
问题标签