@itrocks/mysql-maintainer
Version:
Reactively maintains database structure by updating schema and retrying on MySQL errors
79 lines • 3.07 kB
JavaScript
import { Mysql as M } from '@itrocks/mysql';
import { ReflectProperty } from '@itrocks/reflect';
import { Contextual } from './contextual-connection';
export class Mysql extends M {
async connect() {
return 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 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 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;
}
}
//# sourceMappingURL=mysql.js.map