Created
August 14, 2011 14:27
-
-
Save mikekunze/1144913 to your computer and use it in GitHub Desktop.
Using regular expressions in mongo
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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