Sails.js Waterline native MongoDB query by ID?
<p>I am trying to use the Waterline <code>.native()</code> method to query an item by id in the database. This is what my code looks like:</p>

<pre><code>    // Consutruct the query based on type
    var query = {};

    if (req.param('type') === 'id') {
        query = { _id: req.param('number') };
    } else {
        query = { 'data.confirmationNumber': req.param('number') };
    }

    Confirmations.native(function(error, collection) {
        if (error) {
            ResponseService.send(res, 'error', 500, 'Database error.');
        } else {
            collection.find(query).toArray(function(queryError, queryRecord) {
                if (queryError) {
                    ResponseService.send(res, 'error', 500, 'Database error.');
                } else {
                    if (queryRecord.length &gt; 0) {
                        ResponseService.send(res, 'success', 200, queryRecord[0]);
                    } else {
                        ResponseService.send(res, 'error', 404, 'Your confirmation details could not be found.');
                    }
                }
            });
        }
    });
</code></pre>

<p>When the query is 'data.confirmationNumber' it works but if it is '_id' it dows not work. How do I fix this?</p>