Comparing version 1.0.1 to 1.0.2
@@ -48,2 +48,3 @@ "use strict"; | ||
Object.defineProperty(exports, "fastify", { enumerable: true, get: function () { return _Application_1.fastify; } }); | ||
const orm_1 = require("../orm"); | ||
const ERROR_USER_NOT_LOGIN = new global_1.VError(global_1.GLOBAL_ERROR._USER_NOT_LOGIN); | ||
@@ -59,2 +60,3 @@ exports.registerCache = _Session_1.default.registerCache; | ||
}); | ||
(0, orm_1.setup)({ getConn: () => _Application_1.fastify.pg }); | ||
} | ||
@@ -61,0 +63,0 @@ // REDIS PLUGIN |
@@ -1,2 +0,2 @@ | ||
import { ClientBase } from 'pg'; | ||
import type { ClientBase } from 'pg'; | ||
export declare const deleteById: (pg: ClientBase, table: string, id: string | number, key?: string) => Promise<number>; |
@@ -1,2 +0,2 @@ | ||
import { ClientBase } from 'pg'; | ||
import type { ClientBase } from 'pg'; | ||
export declare const insert: (pg: ClientBase, table: string, obj: any) => Promise<any>; |
@@ -1,2 +0,2 @@ | ||
import { ClientBase } from 'pg'; | ||
import type { ClientBase } from 'pg'; | ||
export declare const update: (pg: ClientBase, table: string, obj: any, key?: string) => Promise<number>; |
import type { QueryResult } from 'pg'; | ||
export declare abstract class BaseQuery { | ||
db(): import("@fastify/postgres").PostgresDb & Record<string, import("@fastify/postgres").PostgresDb>; | ||
db(): import("pg").ClientBase; | ||
sql(sql: string, params?: (string | number | boolean)[]): Promise<QueryResult>; | ||
} |
@@ -1,1 +0,9 @@ | ||
export declare const getDB: () => import("@fastify/postgres").PostgresDb & Record<string, import("@fastify/postgres").PostgresDb>; | ||
import type { ClientBase } from 'pg'; | ||
type Settings = { | ||
getConn?: () => ClientBase; | ||
mode?: 'pg' | 'mysql'; | ||
strict?: boolean; | ||
}; | ||
export declare const getDB: () => ClientBase; | ||
export declare const setup: (settings: Settings) => void; | ||
export {}; |
"use strict"; | ||
// pg 版本 | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.getDB = void 0; | ||
// import type { ClientBase, QueryResult } from 'pg'; | ||
const fastify_1 = require("../../core/fastify"); | ||
// var db: ClientBase = fastify.pg as any; | ||
// var strict = true; | ||
// type Settings = { | ||
// conn?: ClientBase, | ||
// mode?: 'pg' | 'mysql', | ||
// strict?: boolean; | ||
// } | ||
// const GLOBAL = { | ||
// db: null, | ||
// mode: 'pg', | ||
// } | ||
// export const setup = (client, strict = true) => { | ||
// db = client; | ||
// // strict = strict; | ||
// } | ||
const getDB = () => fastify_1.fastify.pg; | ||
exports.setup = exports.getDB = void 0; | ||
const GLOBAL = { | ||
getConn: null, | ||
mode: 'pg', | ||
strict: true | ||
}; | ||
const getDB = () => { | ||
if (GLOBAL.getConn == null) { | ||
throw new Error(); | ||
} | ||
return GLOBAL.getConn(); | ||
}; | ||
exports.getDB = getDB; | ||
const setup = (settings) => { | ||
if (settings.getConn) { | ||
GLOBAL.getConn = settings.getConn; | ||
} | ||
}; | ||
exports.setup = setup; |
@@ -1,1 +0,3 @@ | ||
export * from './domain/BaseTable'; | ||
export { BaseTable } from './domain/BaseTable'; | ||
export { setup } from './domain/Util'; | ||
export * from './domain/types'; |
@@ -17,2 +17,7 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
__exportStar(require("./domain/BaseTable"), exports); | ||
exports.setup = exports.BaseTable = void 0; | ||
var BaseTable_1 = require("./domain/BaseTable"); | ||
Object.defineProperty(exports, "BaseTable", { enumerable: true, get: function () { return BaseTable_1.BaseTable; } }); | ||
var Util_1 = require("./domain/Util"); | ||
Object.defineProperty(exports, "setup", { enumerable: true, get: function () { return Util_1.setup; } }); | ||
__exportStar(require("./domain/types"), exports); |
{ | ||
"name": "eha", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"description": "Eha For ServerLess", | ||
"author": "ada87" | ||
} |
91619
2213