Archives for : 八月2025

第1699天:云开发的 or 查询,要每个字段建一个索引

const whereParams = _.or([{
  shopId: 'xxx',
  touserMchShopId: 'xxx',
}, {
  mchShopId: 'xxx',
  touserShopId: 'xxx',
}])
db.collection(‘msg’)
  .where(whereParams)
  .orderBy(‘createTime’, ‘desc’)
  .get()

对于这样的查询条件,要每个字段建一个索引才能命中,包括 createTime 也要单独建一个索引。

但是 createTime 创建不了索引,问了技术支持的同学,说是系统自带了 createTime 的索引。