You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

29 lines
660 B

/*!
* [node-mongodb-native](https://github.com/mongodb/node-mongodb-native) ObjectId
* @constructor NodeMongoDbObjectId
* @see ObjectId
*/
var ObjectId = require('mongodb').BSONPure.ObjectID;
/*!
* ignore
*/
var ObjectIdToString = ObjectId.toString.bind(ObjectId);
module.exports = exports = ObjectId;
ObjectId.fromString = function(str){
// patch native driver bug in V0.9.6.4
if (!('string' === typeof str && 24 === str.length)) {
throw new Error("Invalid ObjectId");
}
return ObjectId.createFromHexString(str);
};
ObjectId.toString = function(oid){
if (!arguments.length) return ObjectIdToString();
return oid.toHexString();
};