Skip to content

Instantly share code, notes, and snippets.

@mikekunze
Created August 14, 2011 14:27
Show Gist options
  • Save mikekunze/1144913 to your computer and use it in GitHub Desktop.
Save mikekunze/1144913 to your computer and use it in GitHub Desktop.
Using regular expressions in mongo
app.get('/users.json', function(req, res) {
var accounts = mods.mongoose.model('accounts');
var query = modules.url.parse(req.url,true).query;
accounts.find({name: new RegExp(query.query, 'i') }, function(err, docs) {
var results = {
success: true,
results: docs.length,
items: docs
};
res.send(results);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment