@atri-bot/lib-db 1.1.0

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/README.md ADDED
@@ -0,0 +1,3 @@
1
+ # atri-lib-db
2
+
3
+ 数据库存储支持库
@@ -0,0 +1,17 @@
1
+ import { LogLevel, Logger } from '@huan_kong/logger';
2
+ import { Options, Sequelize } from 'sequelize';
3
+
4
+ type DbConfig = Options & {
5
+ debug?: boolean;
6
+ logLevel?: LogLevel;
7
+ baseDir: string;
8
+ };
9
+ declare class Db {
10
+ config: DbConfig;
11
+ logger: Logger;
12
+ sequelize: Sequelize;
13
+ dbs: Record<string, Sequelize>;
14
+ constructor(config: DbConfig);
15
+ }
16
+
17
+ export { Db, type DbConfig };
package/dist/index.js ADDED
@@ -0,0 +1 @@
1
+ import{Logger as r,LogLevel as g}from"@huan_kong/logger";import l from"crypto";import n from"path";import{Sequelize as b}from"sequelize";var d={},i=class{config;logger;sequelize;dbs=d;constructor(e){this.config=e,this.logger=new r({title:"Db",level:e.logLevel??(e.debug?g.DEBUG:void 0)}),"logger"in e||(e.logging=e.debug?o=>this.logger.DEBUG(o):!1);let s={dialect:"sqlite",storage:n.join(e.baseDir,"./db.sqlite"),...e},t=l.createHash("sha256").update(JSON.stringify(s)).digest("hex");this.sequelize=this.dbs[t]??new b(s),this.dbs[t]=this.sequelize}};export{i as Db};
package/package.json ADDED
@@ -0,0 +1,25 @@
1
+ {
2
+ "name": "@atri-bot/lib-db",
3
+ "version": "1.1.0",
4
+ "description": "db lib for atri framework",
5
+ "author": "huan_kong",
6
+ "license": "MIT",
7
+ "type": "module",
8
+ "main": "./dist/index.js",
9
+ "types": "./dist/index.d.ts",
10
+ "files": [
11
+ "./dist/**/*"
12
+ ],
13
+ "scripts": {
14
+ "build": "pnpm run type-check && pnpm run lint && tsup",
15
+ "clean": "rimraf dist",
16
+ "lint": "eslint",
17
+ "lint:fix": "eslint --fix",
18
+ "type-check": "tsc --noEmit -p tsconfig.json --composite false"
19
+ },
20
+ "dependencies": {
21
+ "@huan_kong/logger": "^1.0.6",
22
+ "sequelize": "^6.37.7",
23
+ "sqlite3": "^5.1.7"
24
+ }
25
+ }