数据库字段不存在时,where搜索条件怎么填?
发布于 5 年前 作者 uzhu 7285 次浏览 来自 问答
  • 需求的场景描述(希望解决的问题)

要搜索的数据库字段可能不存在,where里面应该怎么填?

例如:Ethernet字段,要搜索的数据库里面可能没有

const promise = db.collection(event.part).skip(i * MAX_LIMIT).limit(MAX_LIMIT).where({

   Ethernet: event.paras.ethernet > ‘0’ ? _.gte(event.paras.ethernet):

        db.RegExp({

          regexp: “.*”,

          options: ‘i’,

      }),

}).count({

})

我这样填,event.paras.ethernet='0’时,搜到0条记录

我希望event.paras.ethernet ='0’时,don’t care Ethernet字段,该字段存在或者不存在,都不care

  • 希望提供的能力
1 回复

都没人知道吗? 难道我要拿所有的数据回来,自己分析?

回到顶部