hydrate-mongodb
Version:
An Object Document Mapper (ODM) for MongoDB.
45 lines (44 loc) • 1.68 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
var persistenceError_1 = require("../persistenceError");
var Property = (function () {
function Property(name, mapping) {
if (!name) {
throw new persistenceError_1.PersistenceError("Missing required argument 'name'.");
}
if (!mapping) {
throw new persistenceError_1.PersistenceError("Missing required argument 'mapping'.");
}
this.name = name;
this.mapping = mapping;
}
Property.prototype.setFlags = function (flags) {
if (this.flags === undefined) {
this.flags = flags;
}
else {
this.flags |= flags;
}
};
Property.prototype.hasFlags = function (flags) {
return this.flags != undefined && ((this.flags & flags) === flags);
};
Property.prototype.getPropertyValue = function (obj) {
this.getPropertyValue = (new Function("o", "return o['" + this.name + "']"));
return obj[this.name];
};
Property.prototype.setPropertyValue = function (obj, value) {
this.setPropertyValue = (new Function("o,v", "o['" + this.name + "'] = v"));
obj[this.name] = value;
};
Property.prototype.getFieldValue = function (document) {
this.getFieldValue = (new Function("o", "return o['" + this.field + "']"));
return document[this.field];
};
Property.prototype.setFieldValue = function (document, value) {
this.setFieldValue = (new Function("o,v", "o['" + this.field + "'] = v"));
document[this.field] = value;
};
return Property;
}());
exports.Property = Property;