1、在quickstartFunctions文件中新建文件夹和文件
 
 2、index.js 文件书写
 
const cloud = require('wx-server-sdk');
cloud.init({
  env: cloud.DYNAMIC_CURRENT_ENV
});
const db = cloud.database();
// 链表查询试卷和对应的题库
exports.main = async (event, context) => {
    return db.collection('bType').aggregate().match({
      type:event.types,
      status:1
    }).limit(20).lookup({
      from: 'bBank',
      localField: '_id',
      foreignField: 'relative',
      as: 'list',
    })
    .end()
};
**注意:通过连表查询得到的最终数据不能太大,否则会报错!!!**报错如下:
 
 3、quickstartFunctions文件中index.js 必修要修改!如下:
 
4、上传新建的文件和第3步修改的inde.js文件
 
 新建文件夹右键:云函数增量上传:更新文件夹
 index.js文件右键:云函数增量上传:更新文件
5、小程序端调用quickstartFunctions中的云函数:
 
getExam(type){
      wx.cloud.callFunction({
        name: 'quickstartFunctions',
        data: { 
          type: 'getTk', //调用quickstartFunctions下的那个云函数
          types:type //云函数段参数
        }
      }).then(res=>{
        console.log(res);
      })
  },
2023.07.24



















