Skip to content

Instantly share code, notes, and snippets.

@Fandora
Created June 24, 2012 06:22
Show Gist options
  • Select an option

  • Save Fandora/2981942 to your computer and use it in GitHub Desktop.

Select an option

Save Fandora/2981942 to your computer and use it in GitHub Desktop.
mongoose ObjectId
var ObjectId = require("mongoose").Types.ObjectId;
module.exports.toObjectId = function(idstr) {
try {
return ObjectId(idstr);
} catch (err) {
console.log(err);
throw new errors.BadRequest("錯誤的序號");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment