简体   繁体   English

如何在 Nodejs Mongodb 中设置最低价格最高价格参数,并从通过 postman 发布的这些查询中获取数据

[英]How to set min price max price parameters in Nodejs Mongodb, and get data from these queries posted through postman

How to set min price max price parameters in Nodejs Mongodb, and get data from these queries posted through postman.如何在 Nodejs Mongodb 中设置最低价格最高价格参数,并从通过 postman 发布的这些查询中获取数据。

  if (req.query.max_price && req.query.max_price != "") {
      qry.price = { $lte: req.query.max_price };
  }

and

if (req.query.max_price && req.query.max_price != "") {
     qry.price = { $lte: req.query.max_price };
}

But it doesn't follow the parameters given like min_query但它不遵循 min_query 等给出的参数

first of all, you must parse the query input to Int or Float.首先,您必须将查询输入解析为 Int 或 Float。 here is a sample of the code:这是代码示例:

const max = parseInt(req.query.max, 10);
Models.Collection.find({price: {$lte: max}});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM