[英]Query $or in express.js
如何在express.js app.get()函數中查詢$ or? 對於本例中的find()查詢,
db.inventory.find( { $or: [ { quantity: { $lt: 20 } }, { price: 10 } ] } )
我想知道如何轉換為app.get()函數格式:
app.get('/:collection', function(req,res){
var collection = db.get(req.param.collection);
collection.find({}) // Query Part
});
參考: http : //docs.mongodb.org/manual/reference/operator/query/or/
借助express上的mongoose mongo驅動程序,您可以執行此操作,
app.get('/:collection', function(req,res){
//var collection = db.get(req.param.collection);
Collection.find( { $or:[ {'quantity':{ $lt: 20 }}, { price: 10 } ]},
function(err,docs){
if(!err) res.send(docs);
});
});
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.