html52.com
我爱小程序-开发者交流社区

请问云函数中怎么链式调用数据库并返回返回值?

代码大致如下 返回的result为空,没有返回刚刚添加的那条记录

谢谢解答

exports.main = async (event, context) => {
   try {
      var res = await db.collection('table1').add({
         data: {
            ***
         }
      });
      if (res.data._id) {
         await db.collection('table2')
            .where({
               _id: event.id
            })
            .remove();
         return await db.collection('table1')
           .where({
             _id: res.data._id})
           .get();
      } else {
         return "error";
      }
   } catch (err) {
      return err;
   }
}

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

真正的个人免签约支付接口

云免签H5支付