mongoose-id-autoinc icon indicating copy to clipboard operation
mongoose-id-autoinc copied to clipboard

mongojs query with a input query string

Open ghost opened this issue 10 years ago • 0 comments

I wanna do db.collection_name.find(query, function(err, doc){}); in app.js and send doc to next page. But the statement can't return a doc. I don't know why.

Code in the index.jade partly: form(method = 'post', action = '/users/update') span Query Statement: input(name = 'stm') input(type = 'submit', value = 'Exec')

Code in app.js partly: app.post('/users/update', function(req, res){ var statement = req.body.stm; // db.customers.find({id:{$lt:20}}, function(err, doc){ //[1] db.customers.find(statement, function(err, doc){ //[2] console.log('statement: ' + statement); console.log('doc: ' + doc); res.render('users/index',{ title: 'Customer List', docs: doc, }); });

[1] is ok : doc: [object Object],.... [2] got console information: statement: {id:{$lt:20}} doc: when I input {id:{$lt:20}} in the page. doc is nothing

ghost avatar Mar 19 '14 05:03 ghost