redis-orm-node
Version:
`redis-orm` is a lightweight Object-Relational Mapping (ORM) library for Node.js.
35 lines • 1.21 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.internalStorage = void 0;
class InternalStorage {
constructor() {
this.entityMetadata = new WeakMap();
this.propertiesMetadata = [];
this.entityDefinition = new WeakMap();
}
pushEntityOptions(target, options) {
this.entityMetadata.set(target, options);
}
pushColumnOptions(object, propertyName, options) {
this.propertiesMetadata.push({
object, propertyName, options
});
}
getEntityWorkspace(target) {
return {
entityOptions: this.entityMetadata.get(target),
propertyMetadata: this.propertiesMetadata.filter(property => target == property.object.constructor),
};
}
pushEntityDefinition(object, definition) {
this.entityDefinition.set(object, definition);
}
getEntityDefinition(object) {
const EntityDefinition = this.entityDefinition.get(object);
if (!EntityDefinition)
throw new Error(`Entity definition not found`);
return EntityDefinition;
}
}
exports.internalStorage = new InternalStorage;
//# sourceMappingURL=internalStorage.js.map