【已解决】collection.where参数的字段名怎么使用变量?

发布于 6 年前作者 haoguiying12584 次浏览最后编辑 6 年前来自 ask
dbcollection'todos'where
  price _lt100get

字段price,能怎样变量代替,试了一些方法都get不到数据

1 回复
gkang
gkang1 楼4 年前

var   a = ‘price’

db.collection(‘todos’).where({ [a]: _.lt(100)}).get()