示例代码中书写错误

发布于 7 年前作者 na69378 次浏览最后编辑 7 年前来自 issues

https://developers.weixin.qq.com/miniprogram/dev/wxcloud/reference-sdk-api/database/command/Command.elemMatch.html

示例代码:数组元素都是普通数据类型的情况

假设集合示例数据如下:

{
  "_id": "a0",
  "scores": [60, 80, 90]
}

找出 scores 数组字段中至少同时包含一个满足 “大于 80 且小于 100” 的元素

const _ = db.command
db.collection('todos').where({
  places: _.elemMatch(_.gt(80).lt(100))
})
.get()

places应该为scores,正确写法:
const _ = db.command
db.collection('todos').where({
  scores: _.elemMatch(_.gt(80).lt(100))
})
.get()

0 回复
暂无回复