Mongodb $where query always true with nodejs

后端 未结 7 2125
隐瞒了意图╮
隐瞒了意图╮ 2021-01-12 11:01

When I query my database with a function passed in the \"$where\" clause in nodejs, it always return me all documents in the db.

For example, if I do



        
7条回答
  •  萌比男神i
    2021-01-12 11:30

    This one is works for me , Just try to store a query as a string in one variable then concat your variable in query string,

    var local_var = 42

    var query = "{$where: function() { return this.a == "+local_var+"}}"

    db.test.find(query)

提交回复
热议问题