云函数查询中,and有必要吗?
发布于 3 年前 作者 yang19 13654 次浏览 来自 问答

以下两种方式返回结果相同,and 貌似没有必要,如何理解官方文档中“通常需要显示使用 and 是用在有跨字段或操作的时候”?若有必要,请举例说明下。还有怎么算是‘跨字段查询’?

const  = db.command
db.collection(“student”).where(.and([
 .or({
  “balance”:.gt(7)
 }),
 _.or({
  “sname”:“Tom”
 })
])).get();

db.collection(“student”).where({ “balance”:_.gt(7),  “sname”:“Tom” }).get();

2 回复

以你的例子,balance大于7,同时小于10,你怎么写?

回到顶部