javascript - Variable into mongodb query -
ok driving me crazy..
function(amount){ matchingorder = order.findone({ price: { $lte: amount } }, { sort: { price: 1, order_id: 1 } }); }
-----does not work
this works:
function(){ amount = 2 matchingorder = order.findone({ price: { $lte: amount } }, { sort: { price: 1, order_id: 1 } }); }
in both cases console.log(amount) 2 variable gets passed
...sorry maybe obvious scope or something..im relativly new @ this
the thing coming mind different types amount. try instead:
function(amount){ matchingorder = order.findone({ price: { $lte: parseint(amount) } }, { sort: { price: 1, order_id: 1 } }); }
Comments
Post a Comment