@naturalcycles/db-lib
Version:
Lowest Common Denominator API to supported Databases
61 lines (60 loc) • 1.96 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.BaseCommonDB = void 0;
const common_db_1 = require("./common.db");
const dbTransaction_util_1 = require("./transaction/dbTransaction.util");
/**
* No-op implementation of CommonDB interface.
* To be extended by actual implementations.
*/
class BaseCommonDB {
constructor() {
this.dbType = common_db_1.CommonDBType.document;
this.support = {};
}
async ping() {
throw new Error('ping is not implemented');
}
async getTables() {
throw new Error('getTables is not implemented');
}
async getTableSchema(_table) {
throw new Error('getTableSchema is not implemented');
}
async createTable(_table, _schema) {
// no-op
}
async getByIds(_table, _ids) {
throw new Error('getByIds is not implemented');
}
async deleteByQuery(_q) {
throw new Error('deleteByQuery is not implemented');
}
async patchByQuery(_q, _patch, _opt) {
throw new Error('patchByQuery is not implemented');
}
async runQuery(_q) {
throw new Error('runQuery is not implemented');
}
async runQueryCount(_q) {
throw new Error('runQueryCount is not implemented');
}
async saveBatch(_table, _rows, _opt) {
throw new Error('saveBatch is not implemented');
}
streamQuery(_q) {
throw new Error('streamQuery is not implemented');
}
async deleteByIds(_table, _ids, _opt) {
throw new Error('deleteByIds is not implemented');
}
async runInTransaction(fn, _opt) {
const tx = new dbTransaction_util_1.FakeDBTransaction(this);
await fn(tx);
// there's no try/catch and rollback, as there's nothing to rollback
}
async incrementBatch(_table, _prop, _incrementMap, _opt) {
throw new Error('incrementBatch is not implemented');
}
}
exports.BaseCommonDB = BaseCommonDB;