where写法的问题, 很不明白
发布于 6 年前 作者 xiazhang 8404 次浏览 来自 问答
  • 当前 Bug 的表现(可附上截图)
const cloud = require("wx-server-sdk");
cloud.init();
const db = cloud.database();
const _ = db.command;
 
exports.main = async (data = {}, context) => {
  try {
    if (data.userId) {
      return getMatchByUserId(data.userId);
    }
    return getMatchByCondi(data);
  } catch (e) {
    console.error(e);
  }
};
async function getMatchByCondi(data) {
  return await db
    .collection("match")
    .where(data)
    .get();
}
 
async function getMatchByUserId(userId) {
  return await db
    .collection("match")
    .where({
      peoples: db.RegExp({
        regexp: ".*" + userId
      })
    })
    .get();
}

本地调试的时候可以查出来数据, 关掉本地调试的时候就查不出来了.

data 传值会有  data ={ status: 1 }

  • 预期表现

关掉本地调试上传到线上依然可以查出数据

回到顶部