hydrate-mongodb
Version:
An Object Document Mapper (ODM) for MongoDB.
50 lines (49 loc) • 2.24 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 classMappingBuilder_1 = require("./classMappingBuilder");
var mappingModel_1 = require("../mappingModel");
var EntityMappingBuilder = (function (_super) {
__extends(EntityMappingBuilder, _super);
function EntityMappingBuilder() {
return _super !== null && _super.apply(this, arguments) || this;
}
EntityMappingBuilder.prototype.populateCore = function () {
_super.prototype.populateCore.call(this);
var mapping = this.mapping;
if (mapping.hasFlags(4096)) {
if (mapping.versioned == null) {
mapping.versioned = this.context.config.versioned;
}
if (mapping.versionField == null) {
mapping.versionField = this.context.config.versionField;
}
if (mapping.changeTracking == null) {
mapping.changeTracking = this.context.config.changeTracking;
}
if (mapping.collectionName == null) {
mapping.collectionName = this.context.config.collectionNamingStrategy(mapping.name);
}
if (this.context.config.collectionPrefix) {
mapping.collectionName = this.context.config.collectionPrefix + mapping.collectionName;
}
if (mapping.identity == null) {
mapping.identity = this.context.config.identityGenerator;
}
if (mapping.versioned) {
mapping.addIndex({ keys: [["_id", 1], [mapping.versionField, 1]] });
}
}
};
return EntityMappingBuilder;
}(classMappingBuilder_1.ClassMappingBuilder));
exports.EntityMappingBuilder = EntityMappingBuilder;