Skip to content

Instantly share code, notes, and snippets.

@jrf0110
Created June 21, 2012 21:29
Show Gist options
  • Save jrf0110/2968636 to your computer and use it in GitHub Desktop.
Save jrf0110/2968636 to your computer and use it in GitHub Desktop.
Type Checking with leFunc
// Call api.one with any argument combo
api.one = leFunc({
"String, Function":
function(id , callback){
api.one(new ObjectId(id), {}, callback);
}
, "Object, Function":
function(id , callback){
api.one(id, {}, callback);
}
, "String, Object, Function":
function(id , fields, callback){
api.one(new ObjectId(id), fields, callback);
}
, "Object, Object, Function":
function(id , fields, callback){
var data = (id instanceof ObjectId) ? { _id: id } : id;
this.collection.findOne({ _id: id }, fields, callback);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment