hydrate-mongodb
Version:
An Object Document Mapper (ODM) for MongoDB.
48 lines (47 loc) • 1.82 kB
JavaScript
;
var __extends = (this && this.__extends) || (function () {
var extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
var RegExpUtil = require("../core/regExpUtil");
var mappingBase_1 = require("./mappingBase");
var mappingModel_1 = require("./mappingModel");
var RegExpMapping = (function (_super) {
__extends(RegExpMapping, _super);
function RegExpMapping() {
return _super.call(this, 128) || this;
}
RegExpMapping.prototype.read = function (context, value) {
if (value == null)
return null;
if (!(value instanceof RegExp)) {
context.addError("Expected RegExp.");
return;
}
return RegExpUtil.clone(value);
};
RegExpMapping.prototype.write = function (context, value) {
if (value == null)
return null;
if (!(value instanceof RegExp)) {
context.addError("Expected RegExp.");
return;
}
return RegExpUtil.clone(value);
};
RegExpMapping.prototype.areEqual = function (documentValue1, documentValue2) {
if (documentValue1 instanceof RegExp && documentValue2 instanceof RegExp) {
return documentValue1.toString() == documentValue2.toString();
}
return false;
};
return RegExpMapping;
}(mappingBase_1.MappingBase));
exports.RegExpMapping = RegExpMapping;