@mrnafisia/type-query
Advanced tools
Comparing version 1.0.0 to 1.0.1
@@ -1,5 +0,7 @@ | ||
import type { Pool } from './types/pool'; | ||
import type { AddHook, Pool, RemoveHook } from './types/pool'; | ||
declare const addHook: AddHook; | ||
declare const removeHook: RemoveHook; | ||
declare const createPool: (connectionString: string) => Pool; | ||
export { Pool }; | ||
export { addHook, removeHook }; | ||
export default createPool; | ||
//# sourceMappingURL=pool.d.ts.map |
@@ -39,4 +39,30 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.removeHook = exports.addHook = void 0; | ||
var pg_1 = require("pg"); | ||
var dictionary_1 = require("./dictionary"); | ||
var submit = pg_1.Query.prototype.submit; | ||
pg_1.Query.prototype.submit = function () { | ||
var _this = this; | ||
onSendQueryHooks.forEach(function (hook) { return hook(_this.text, _this.values); }); | ||
submit.apply(this, arguments); | ||
}; | ||
var onSendQueryHooks = []; | ||
var addHook = function (_a) { | ||
var event = _a.event, hook = _a.hook; | ||
switch (event) { | ||
case 'on-send-query': | ||
onSendQueryHooks.push(hook); | ||
break; | ||
} | ||
}; | ||
exports.addHook = addHook; | ||
var removeHook = function (_a) { | ||
var event = _a.event, hook = _a.hook; | ||
switch (event) { | ||
case 'on-send-query': | ||
onSendQueryHooks.splice(onSendQueryHooks.indexOf(hook), 1); | ||
break; | ||
} | ||
}; | ||
exports.removeHook = removeHook; | ||
var createPool = function (connectionString) { | ||
@@ -43,0 +69,0 @@ var pool = new pg_1.Pool({ connectionString: connectionString }); |
import type { Result } from 'never-catch'; | ||
import type { Pool as PgPool, PoolClient } from 'pg'; | ||
import { Param } from "./entity"; | ||
declare type TransactionIsolationLevel = 'read-uncommitted' | 'read-committed' | 'repeatable-read' | 'serializable'; | ||
@@ -8,3 +9,12 @@ declare type Pool = { | ||
}; | ||
export type { TransactionIsolationLevel, Pool }; | ||
declare type OnSendQueryHook = (query: string, params: Param[]) => void; | ||
declare type AddHook = (hookAndEvent: { | ||
event: 'on-send-query'; | ||
hook: OnSendQueryHook; | ||
}) => void; | ||
declare type RemoveHook = (hookAndEvent: { | ||
event: 'on-send-query'; | ||
hook: OnSendQueryHook; | ||
}) => void; | ||
export type { TransactionIsolationLevel, Pool, OnSendQueryHook, AddHook, RemoveHook }; | ||
//# sourceMappingURL=pool.d.ts.map |
{ | ||
"name": "@mrnafisia/type-query", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "mini-orm with full type support for postgres.", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1481819
23936