UNPKG

hydrate-mongodb

Version:
30 lines (29 loc) 991 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var mongodb_1 = require("mongodb"); var ObjectIdGenerator = (function () { function ObjectIdGenerator() { mongodb_1.ObjectID.cacheHexString = true; } ObjectIdGenerator.prototype.generate = function () { return new mongodb_1.ObjectID(); }; ObjectIdGenerator.prototype.validate = function (value) { if (value == null) return false; if (value._bsontype && value._bsontype == 'ObjectID') return true; return false; }; ObjectIdGenerator.prototype.fromString = function (text) { if (text == null || text.length != 24) { return null; } return mongodb_1.ObjectID.createFromHexString(text); }; ObjectIdGenerator.prototype.areEqual = function (first, second) { return first.equals(second); }; return ObjectIdGenerator; }()); exports.ObjectIdGenerator = ObjectIdGenerator;