perform a mongoose query in querystring
<p>I'm trying to do a simple mongoose query using the query string.
This works</p>

<pre><code>router.get('/', function(req,res) {
    myModel.find({name:"test e"}, function(err,data){
        if(err) console.log(err)
        res.json(data);
    });

});
</code></pre>

<p>This doesn't work (I get the whole collection)..</p>

<pre><code>router.get('/', function(req,res) {
    console.log(req.query.q)
    myModel.find(req.query.q, function(err,data){
        if(err) console.log(err)
        res.json(data);
    });

});
</code></pre>

<p>with this request</p>

<pre><code>/api/myModel?q={name:"test e"}
</code></pre>

<p>I don't think it's an url encoding issue since I print the 'q' var and it looks fine server side.</p>

<p>Side question: if this isn't the standard mode, what's the RESTful standard way to query a db?</p>

<p><strong>Edit for more general details:</strong>
I don't need a simple access by id or name like Ashley B suggests, I need a proper search engine for my db (the user, using a graphic web interface, have to be able to query each field separately, potentially)</p>

<p><strong>Edit 2:</strong>
thanks to Blakes Seven I solved my initial problem, but if you know or use a better way to perform a complex query I would happy to discuss. <em>Maybe I should expose anther resource "/api/seach"?</em></p>