Created
April 22, 2015 16:08
-
-
Save Miniwe/18a62b00f3cd94dee993 to your computer and use it in GitHub Desktop.
Revisions
-
Miniwe created this gist
Apr 22, 2015 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,9 @@ var ObjectId = require('mongoose').Types.ObjectId; var objId = new ObjectId( (param.length < 12) ? "123456789012" : param ); // You should make string 'param' as ObjectId type. To avoid exception, // the 'param' must consist of more than 12 characters. User.find( { $or:[ {'_id':objId}, {'name':param}, {'nickname':param} ]}, function(err,docs){ if(!err) res.send(docs); });