UNPKG

@itrocks/mysql-maintainer

Version:

Reactively maintains database structure by updating schema and retrying on MySQL errors

83 lines 3.25 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Mysql = void 0; const mysql_1 = require("@itrocks/mysql"); const reflect_1 = require("@itrocks/reflect"); const contextual_connection_1 = require("./contextual-connection"); class Mysql extends mysql_1.Mysql { async connect() { return contextual_connection_1.Contextual.prototype.applyTo(await super.connect()); } async deleteId(type, id, property = 'id') { const context = (this.connection ?? await this.connect()).context; context.push(type); const result = await super.deleteId(type, id, property); context.pop(); return result; } async deleteRelatedId(object, property, id) { const context = (this.connection ?? await this.connect()).context; context.push(object); const result = await super.deleteRelatedId(object, property, id); context.pop(); return result; } async insert(object) { const context = (this.connection ?? await this.connect()).context; context.push(object); const result = await super.insert(object); context.pop(); return result; } async insertRelatedId(object, property, id) { const context = (this.connection ?? await this.connect()).context; context.push(object); const result = await super.insertRelatedId(object, property, id); context.pop(); return result; } async read(type, id) { const context = (this.connection ?? await this.connect()).context; context.push(type); const result = await super.read(type, id); context.pop(); return result; } async readCollection(object, property, type = new reflect_1.ReflectProperty(object, property).collectionType.elementType) { const context = (this.connection ?? await this.connect()).context; context.push([object, type]); const result = await super.readCollection(object, property, type); context.pop(); return result; } async readCollectionIds(object, property, type = new reflect_1.ReflectProperty(object, property).collectionType.elementType) { const context = (this.connection ?? await this.connect()).context; context.push([object, type]); const result = await super.readCollectionIds(object, property, type); context.pop(); return result; } async readMultiple(type, ids) { const context = (this.connection ?? await this.connect()).context; context.push(type); const result = await super.readMultiple(type, ids); context.pop(); return result; } async search(type, search = {}) { const context = (this.connection ?? await this.connect()).context; context.push(type); const result = await super.search(type, search); context.pop(); return result; } async update(object) { const context = (this.connection ?? await this.connect()).context; context.push(object); const result = await super.update(object); context.pop(); return result; } } exports.Mysql = Mysql; //# sourceMappingURL=mysql.js.map