@atri-bot/lib-db 2.0.0 → 2.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +5 -5
- package/dist/index.mjs +1 -1
- package/package.json +2 -2
package/dist/index.d.mts
CHANGED
|
@@ -6,24 +6,24 @@ import { MigrationConfig } from "drizzle-orm/migrator";
|
|
|
6
6
|
//#region src/index.d.ts
|
|
7
7
|
interface InitDbPluginOptions {
|
|
8
8
|
connectString: string;
|
|
9
|
-
config
|
|
9
|
+
config?: DrizzleConfig;
|
|
10
10
|
}
|
|
11
|
-
declare function InitDbPlugin(options: InitDbPluginOptions): _atri_bot_core0.definePluginReturnType<
|
|
11
|
+
declare function InitDbPlugin(options: InitDbPluginOptions): _atri_bot_core0.definePluginReturnType<{
|
|
12
12
|
pluginName: string;
|
|
13
13
|
install(): Promise<void>;
|
|
14
14
|
uninstall(): void;
|
|
15
|
-
}>;
|
|
15
|
+
}, object>;
|
|
16
16
|
interface DbPluginOptions<TSchema extends Record<string, unknown>, TRelations extends AnyRelations> {
|
|
17
17
|
config: DrizzleConfig<TSchema, TRelations>;
|
|
18
18
|
migration?: MigrationConfig;
|
|
19
19
|
}
|
|
20
|
-
declare function DbPlugin<TSchema extends Record<string, unknown>, TRelations extends AnyRelations = EmptyRelations>(options: DbPluginOptions<TSchema, TRelations>): _atri_bot_core0.definePluginReturnType<
|
|
20
|
+
declare function DbPlugin<TSchema extends Record<string, unknown>, TRelations extends AnyRelations = EmptyRelations>(options: DbPluginOptions<TSchema, TRelations>): _atri_bot_core0.definePluginReturnType<{
|
|
21
21
|
pluginName: string;
|
|
22
22
|
drizzle: drizzle_orm_bun_sql_postgres_driver0.BunSQLDatabase<TSchema, TRelations> & {
|
|
23
23
|
$client: Bun.SQL;
|
|
24
24
|
};
|
|
25
25
|
install(): Promise<void>;
|
|
26
26
|
uninstall(): void;
|
|
27
|
-
}>;
|
|
27
|
+
}, object>;
|
|
28
28
|
//#endregion
|
|
29
29
|
export { DbPlugin, DbPluginOptions, InitDbPlugin, InitDbPluginOptions };
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import e from"node:process";import{definePlugin as t}from"@atri-bot/core";import{sql as n}from"drizzle-orm";import{drizzle as r}from"drizzle-orm/bun-sql";import{migrate as i}from"drizzle-orm/bun-sql/migrator";var a=`@atri-bot/lib-db`;let o=null;function s(i){return t({pluginName:`${a}-init-db`,async install(){try{await r(i.connectString,i.config).execute(n`SELECT 1;`),o=i
|
|
1
|
+
import e from"node:process";import{definePlugin as t}from"@atri-bot/core";import{sql as n}from"drizzle-orm";import{drizzle as r}from"drizzle-orm/bun-sql";import{migrate as i}from"drizzle-orm/bun-sql/migrator";var a=`@atri-bot/lib-db`;let o=null;function s(i){return t({pluginName:`${a}-init-db`,async install(){try{await r(i.connectString,i.config??{}).execute(n`SELECT 1;`),o=i,this.logger.INFO(`测试数据库连接成功`)}catch(t){this.logger.ERROR(`测试数据库连接失败`,t),e.exit(1)}},uninstall(){}})}function c(e){if(!o)throw Error(`请先通过 InitDbPlugin 插件初始化数据库连接`);return t({pluginName:`${a}-db`,drizzle:r(o.connectString,{...o.config,...e.config}),async install(){e.migration&&await i(this.drizzle,e.migration)},uninstall(){}})}export{c as DbPlugin,s as InitDbPlugin};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atri-bot/lib-db",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "2.0.
|
|
4
|
+
"version": "2.0.2",
|
|
5
5
|
"description": "db lib for atri framework",
|
|
6
6
|
"author": "huan_kong",
|
|
7
7
|
"license": "MIT",
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"typecheck": "tsc --noEmit -p tsconfig.json --composite false"
|
|
17
17
|
},
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"@atri-bot/core": "^2.0.
|
|
19
|
+
"@atri-bot/core": "^2.0.2",
|
|
20
20
|
"@huan_kong/logger": "^2.0.2",
|
|
21
21
|
"drizzle-orm": "^1.0.0-beta.19"
|
|
22
22
|
}
|