@decaf-ts/db-decorators
Version:
Agnostic database decorators and repository
45 lines • 2.06 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
require("@decaf-ts/decorator-validation");
const decorator_validation_1 = require("@decaf-ts/decorator-validation");
const decorators_js_1 = require("./../model/decorators.cjs");
const builderPrototype = decorator_validation_1.ModelBuilder.prototype;
if (!builderPrototype.decorateClass) {
builderPrototype.decorateClass = function (decorator) {
if (!this._classDecorators) {
this._classDecorators = [];
}
this._classDecorators.push(decorator);
return this;
};
}
const ensureAttributeBuilder = (builder, attr) => {
const attributes = builder.attributes;
if (attributes?.has(attr))
return attributes.get(attr);
return builder.attribute(attr, Object);
};
const applyDecorator = (builder, attr, decorator) => {
ensureAttributeBuilder(builder, attr).decorate(decorator);
return builder;
};
builderPrototype.generated = function (attr, type) {
return applyDecorator(this, attr, (0, decorators_js_1.generated)(type));
};
builderPrototype.hash = function (attr) {
return applyDecorator(this, attr, (0, decorators_js_1.hash)());
};
builderPrototype.composedFromKeys = function (attr, args, separator, filterEmpty, hashValue, prefix, suffix, groupsort) {
return applyDecorator(this, attr, (0, decorators_js_1.composedFromKeys)(args, separator, filterEmpty, hashValue, prefix, suffix, groupsort));
};
builderPrototype.composed = function (attr, args, separator, filterEmpty, hashValue, prefix, suffix, groupsort) {
return applyDecorator(this, attr, (0, decorators_js_1.composed)(args, separator, filterEmpty, hashValue, prefix, suffix, groupsort));
};
builderPrototype.version = function (attr) {
return applyDecorator(this, attr, (0, decorators_js_1.version)());
};
builderPrototype.transient = function (attr) {
return applyDecorator(this, attr, (0, decorators_js_1.transient)());
};
//# sourceMappingURL=ModelBuilderExtensions.js.map
//# sourceMappingURL=ModelBuilderExtensions.js.map