@ haatlabs- core/ db- core
每个应用程序的数据库代码共享, 在PostgreSQL 有细雨。 db-core 没有桌子 并且没有迁移:每个应用程序宣布自己的表格并撰写其迁移。 它拥有的是 共享的柱子, 和对它们起作用的代码.
-
createDatabase(url, { max }):一个游泳池,其close()等待每一个连接.Database输入时没有计划( 完全不用细雨的关系查询) , 所以 每个应用程序都有一个类型. -
withTenant(db, ctx, fn): 与app.organization_id(单位:千美元)TENANT_SETTING(中文(简体) ) 锁定行级安全。 每个应用程序的政策都读取了这个设定. -
runMigrations(systemUrl, { migrationsFolder }), (中文(简体) ),runMigrationsCli(...)。 。 。 . -
@haatlabs-core/db-core/testing数字 :startTestDatabase({ name, migrationsFolder, afterMigrate }), (中文(简体) ), a 在容器中迁移的 PostgreSQL(需要)@testcontainers/postgresql) (中文(简体) ). -
列组 用于共享表格及其索引,一个应用程序从中构建:
export const organizations = pgTable('organizations', { ...organizationColumns(), storeLimit: integer('store_limit'), // the app's own: nullable or with a default }); export const memberships = pgTable('memberships', membershipColumns({ users, organizations }), (t) => membershipIndexes(t)); export { organizationOriginEnum, roleEnum } from '@haatlabs-core/db-core'; // for drizzle-kit -
仓库 使用应用程序的表格:
IdentityRepository, (中文(简体) ),ApiKeyRepository, (中文(简体) ),WebhookEventRepository, (中文(简体) ),OutboxRepository(单位:千美元)priority: 应用程序的列, 或false, (中文(简体) ),PlatformAdminRepository。缺少共享列的表格不汇编 库已建立. -
createOutboxWriter, (中文(简体) ),createAuditWriter, (中文(简体) ),isUniqueViolation。 。 。 .
drizzle-orm 财务报告和审定财务报表 pg 是同伴: 使用该应用程序自己的副本.
计费栏 (自0.5.0起): planColumns, (中文(简体) ), planFeatureColumns, (中文(简体) ), planPriceColumns, (中文(简体) ),
subscriptionColumns, (中文(简体) ), paymentEventColumns, (中文(简体) ), usageRecordColumns, (中文(简体) ),
organizationFeatureColumns各有其索引; organizations.store_limit; 和
收发箱 outboxPriorityColumn(),其默认值 organization_goes_first() 一个应用程序
从 ORGANIZATION_GOES_FIRST_SQL 在发件箱前.
insertOutbox.many(tx, messages) 写许多出柜行,每500个内插一个
交易。 发件箱行没有 delayMs 没有 deduplication (@haatlabs-core/quue),所以一个
发布这些需要是在承诺之后直接制作的,如果进程死亡则丢失
二者之间. 一个需要信息才能活下来的打电话者 把它写到收发箱,没有
他们和众仆,是同舟共济的.
安装
pnpm add @haatlabs-core/db-core
这些软件包留给你的应用程序,所以应用程序持有一份: drizzle-orm, (中文(简体) ), pg, (中文(简体) ), @testcontainers/postgresql。 。 。 .