drizzle-orm 0.33.0-87d7704 → 0.33.0-8944ef1
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/better-sqlite3/driver.cjs +7 -1
- package/better-sqlite3/driver.cjs.map +1 -1
- package/better-sqlite3/driver.d.cts +4 -1
- package/better-sqlite3/driver.d.ts +4 -1
- package/better-sqlite3/driver.js +6 -1
- package/better-sqlite3/driver.js.map +1 -1
- package/bun-sqlite/driver.cjs +7 -1
- package/bun-sqlite/driver.cjs.map +1 -1
- package/bun-sqlite/driver.d.cts +4 -1
- package/bun-sqlite/driver.d.ts +4 -1
- package/bun-sqlite/driver.js +6 -1
- package/bun-sqlite/driver.js.map +1 -1
- package/expo-sqlite/driver.cjs +7 -1
- package/expo-sqlite/driver.cjs.map +1 -1
- package/expo-sqlite/driver.d.cts +4 -1
- package/expo-sqlite/driver.d.ts +4 -1
- package/expo-sqlite/driver.js +6 -1
- package/expo-sqlite/driver.js.map +1 -1
- package/index.cjs +2 -0
- package/index.cjs.map +1 -1
- package/index.d.cts +1 -0
- package/index.d.ts +1 -0
- package/index.js +1 -0
- package/index.js.map +1 -1
- package/libsql/migrator.cjs +1 -1
- package/libsql/migrator.cjs.map +1 -1
- package/libsql/migrator.d.cts +1 -1
- package/libsql/migrator.d.ts +1 -1
- package/libsql/migrator.js +1 -1
- package/libsql/migrator.js.map +1 -1
- package/libsql/session.cjs +12 -0
- package/libsql/session.cjs.map +1 -1
- package/libsql/session.d.cts +1 -0
- package/libsql/session.d.ts +1 -0
- package/libsql/session.js +12 -0
- package/libsql/session.js.map +1 -1
- package/monodriver.cjs +123 -29
- package/monodriver.cjs.map +1 -1
- package/monodriver.d.cts +89 -47
- package/monodriver.d.ts +89 -47
- package/monodriver.js +123 -29
- package/monodriver.js.map +1 -1
- package/monomigrator.cjs +95 -0
- package/monomigrator.cjs.map +1 -0
- package/monomigrator.d.cts +15 -0
- package/monomigrator.d.ts +15 -0
- package/monomigrator.js +61 -0
- package/monomigrator.js.map +1 -0
- package/mysql-core/db.cjs +4 -0
- package/mysql-core/db.cjs.map +1 -1
- package/mysql-core/db.d.cts +4 -1
- package/mysql-core/db.d.ts +4 -1
- package/mysql-core/db.js +4 -0
- package/mysql-core/db.js.map +1 -1
- package/mysql-core/query-builders/count.cjs +73 -0
- package/mysql-core/query-builders/count.cjs.map +1 -0
- package/mysql-core/query-builders/count.d.cts +27 -0
- package/mysql-core/query-builders/count.d.ts +27 -0
- package/mysql-core/query-builders/count.js +49 -0
- package/mysql-core/query-builders/count.js.map +1 -0
- package/mysql-core/session.cjs +6 -0
- package/mysql-core/session.cjs.map +1 -1
- package/mysql-core/session.d.cts +1 -0
- package/mysql-core/session.d.ts +1 -0
- package/mysql-core/session.js +6 -0
- package/mysql-core/session.js.map +1 -1
- package/mysql-proxy/driver.cjs +7 -1
- package/mysql-proxy/driver.cjs.map +1 -1
- package/mysql-proxy/driver.d.cts +4 -1
- package/mysql-proxy/driver.d.ts +4 -1
- package/mysql-proxy/driver.js +6 -1
- package/mysql-proxy/driver.js.map +1 -1
- package/mysql2/driver.cjs +6 -1
- package/mysql2/driver.cjs.map +1 -1
- package/mysql2/driver.d.cts +3 -1
- package/mysql2/driver.d.ts +3 -1
- package/mysql2/driver.js +5 -1
- package/mysql2/driver.js.map +1 -1
- package/mysql2/migrator.cjs +4 -1
- package/mysql2/migrator.cjs.map +1 -1
- package/mysql2/migrator.d.cts +1 -1
- package/mysql2/migrator.d.ts +1 -1
- package/mysql2/migrator.js +4 -1
- package/mysql2/migrator.js.map +1 -1
- package/neon/index.cjs +23 -0
- package/neon/index.cjs.map +1 -0
- package/neon/index.d.cts +1 -0
- package/neon/index.d.ts +1 -0
- package/neon/index.js +2 -0
- package/neon/index.js.map +1 -0
- package/neon/rls.cjs +81 -0
- package/neon/rls.cjs.map +1 -0
- package/neon/rls.d.cts +13 -0
- package/neon/rls.d.ts +13 -0
- package/neon/rls.js +54 -0
- package/neon/rls.js.map +1 -0
- package/neon-http/session.cjs +6 -0
- package/neon-http/session.cjs.map +1 -1
- package/neon-http/session.d.cts +2 -1
- package/neon-http/session.d.ts +2 -1
- package/neon-http/session.js +6 -0
- package/neon-http/session.js.map +1 -1
- package/neon-serverless/driver.cjs +6 -1
- package/neon-serverless/driver.cjs.map +1 -1
- package/neon-serverless/driver.d.cts +3 -1
- package/neon-serverless/driver.d.ts +3 -1
- package/neon-serverless/driver.js +5 -1
- package/neon-serverless/driver.js.map +1 -1
- package/node-postgres/driver.cjs +6 -1
- package/node-postgres/driver.cjs.map +1 -1
- package/node-postgres/driver.d.cts +3 -1
- package/node-postgres/driver.d.ts +3 -1
- package/node-postgres/driver.js +5 -1
- package/node-postgres/driver.js.map +1 -1
- package/node-postgres/session.cjs +6 -0
- package/node-postgres/session.cjs.map +1 -1
- package/node-postgres/session.d.cts +2 -1
- package/node-postgres/session.d.ts +2 -1
- package/node-postgres/session.js +6 -0
- package/node-postgres/session.js.map +1 -1
- package/op-sqlite/driver.cjs +7 -1
- package/op-sqlite/driver.cjs.map +1 -1
- package/op-sqlite/driver.d.cts +4 -1
- package/op-sqlite/driver.d.ts +4 -1
- package/op-sqlite/driver.js +6 -1
- package/op-sqlite/driver.js.map +1 -1
- package/operations.cjs.map +1 -1
- package/package.json +101 -5
- package/pg-core/db.cjs +4 -0
- package/pg-core/db.cjs.map +1 -1
- package/pg-core/db.d.cts +5 -2
- package/pg-core/db.d.ts +5 -2
- package/pg-core/db.js +4 -0
- package/pg-core/db.js.map +1 -1
- package/pg-core/index.cjs +4 -0
- package/pg-core/index.cjs.map +1 -1
- package/pg-core/index.d.cts +2 -0
- package/pg-core/index.d.ts +2 -0
- package/pg-core/index.js +2 -0
- package/pg-core/index.js.map +1 -1
- package/pg-core/policies.cjs +52 -0
- package/pg-core/policies.cjs.map +1 -0
- package/pg-core/policies.d.cts +22 -0
- package/pg-core/policies.d.ts +22 -0
- package/pg-core/policies.js +27 -0
- package/pg-core/policies.js.map +1 -0
- package/pg-core/query-builders/count.cjs +73 -0
- package/pg-core/query-builders/count.cjs.map +1 -0
- package/pg-core/query-builders/count.d.cts +26 -0
- package/pg-core/query-builders/count.d.ts +26 -0
- package/pg-core/query-builders/count.js +49 -0
- package/pg-core/query-builders/count.js.map +1 -0
- package/pg-core/roles.cjs +57 -0
- package/pg-core/roles.cjs.map +1 -0
- package/pg-core/roles.d.cts +13 -0
- package/pg-core/roles.d.ts +13 -0
- package/pg-core/roles.js +32 -0
- package/pg-core/roles.js.map +1 -0
- package/pg-core/session.cjs +6 -0
- package/pg-core/session.cjs.map +1 -1
- package/pg-core/session.d.cts +1 -0
- package/pg-core/session.d.ts +1 -0
- package/pg-core/session.js +6 -0
- package/pg-core/session.js.map +1 -1
- package/pg-core/table.cjs.map +1 -1
- package/pg-core/table.d.cts +2 -1
- package/pg-core/table.d.ts +2 -1
- package/pg-core/table.js.map +1 -1
- package/pg-core/utils.cjs +23 -2
- package/pg-core/utils.cjs.map +1 -1
- package/pg-core/utils.d.cts +2 -0
- package/pg-core/utils.d.ts +2 -0
- package/pg-core/utils.js +23 -2
- package/pg-core/utils.js.map +1 -1
- package/pg-proxy/driver.cjs +7 -1
- package/pg-proxy/driver.cjs.map +1 -1
- package/pg-proxy/driver.d.cts +4 -1
- package/pg-proxy/driver.d.ts +4 -1
- package/pg-proxy/driver.js +6 -1
- package/pg-proxy/driver.js.map +1 -1
- package/pg-proxy/session.cjs.map +1 -1
- package/pg-proxy/session.js.map +1 -1
- package/pglite/driver.cjs +6 -1
- package/pglite/driver.cjs.map +1 -1
- package/pglite/driver.d.cts +3 -1
- package/pglite/driver.d.ts +3 -1
- package/pglite/driver.js +5 -1
- package/pglite/driver.js.map +1 -1
- package/pglite/session.cjs +6 -0
- package/pglite/session.cjs.map +1 -1
- package/pglite/session.d.cts +2 -1
- package/pglite/session.d.ts +2 -1
- package/pglite/session.js +6 -0
- package/pglite/session.js.map +1 -1
- package/planetscale-serverless/driver.cjs +7 -1
- package/planetscale-serverless/driver.cjs.map +1 -1
- package/planetscale-serverless/driver.d.cts +4 -1
- package/planetscale-serverless/driver.d.ts +4 -1
- package/planetscale-serverless/driver.js +6 -1
- package/planetscale-serverless/driver.js.map +1 -1
- package/planetscale-serverless/migrator.cjs +4 -1
- package/planetscale-serverless/migrator.cjs.map +1 -1
- package/planetscale-serverless/migrator.d.cts +1 -1
- package/planetscale-serverless/migrator.d.ts +1 -1
- package/planetscale-serverless/migrator.js +4 -1
- package/planetscale-serverless/migrator.js.map +1 -1
- package/planetscale-serverless/session.cjs +6 -0
- package/planetscale-serverless/session.cjs.map +1 -1
- package/planetscale-serverless/session.d.cts +1 -0
- package/planetscale-serverless/session.d.ts +1 -0
- package/planetscale-serverless/session.js +6 -0
- package/planetscale-serverless/session.js.map +1 -1
- package/postgres-js/driver.cjs +7 -1
- package/postgres-js/driver.cjs.map +1 -1
- package/postgres-js/driver.d.cts +4 -1
- package/postgres-js/driver.d.ts +4 -1
- package/postgres-js/driver.js +6 -1
- package/postgres-js/driver.js.map +1 -1
- package/sqlite-core/columns/blob.d.cts +1 -1
- package/sqlite-core/columns/blob.d.ts +1 -1
- package/sqlite-core/db.cjs +4 -0
- package/sqlite-core/db.cjs.map +1 -1
- package/sqlite-core/db.d.cts +4 -1
- package/sqlite-core/db.d.ts +4 -1
- package/sqlite-core/db.js +4 -0
- package/sqlite-core/db.js.map +1 -1
- package/sqlite-core/query-builders/count.cjs +72 -0
- package/sqlite-core/query-builders/count.cjs.map +1 -0
- package/sqlite-core/query-builders/count.d.cts +27 -0
- package/sqlite-core/query-builders/count.d.ts +27 -0
- package/sqlite-core/query-builders/count.js +48 -0
- package/sqlite-core/query-builders/count.js.map +1 -0
- package/sqlite-core/session.cjs +4 -0
- package/sqlite-core/session.cjs.map +1 -1
- package/sqlite-core/session.d.cts +1 -0
- package/sqlite-core/session.d.ts +1 -0
- package/sqlite-core/session.js +4 -0
- package/sqlite-core/session.js.map +1 -1
- package/tidb-serverless/driver.cjs +7 -1
- package/tidb-serverless/driver.cjs.map +1 -1
- package/tidb-serverless/driver.d.cts +4 -1
- package/tidb-serverless/driver.d.ts +4 -1
- package/tidb-serverless/driver.js +6 -1
- package/tidb-serverless/driver.js.map +1 -1
- package/tidb-serverless/session.cjs +6 -0
- package/tidb-serverless/session.cjs.map +1 -1
- package/tidb-serverless/session.d.cts +1 -0
- package/tidb-serverless/session.d.ts +1 -0
- package/tidb-serverless/session.js +6 -0
- package/tidb-serverless/session.js.map +1 -1
- package/vercel-postgres/driver.cjs +6 -1
- package/vercel-postgres/driver.cjs.map +1 -1
- package/vercel-postgres/driver.d.cts +3 -1
- package/vercel-postgres/driver.d.ts +3 -1
- package/vercel-postgres/driver.js +5 -1
- package/vercel-postgres/driver.js.map +1 -1
- package/version.cjs +2 -2
- package/version.cjs.map +1 -1
- package/version.d.cts +2 -2
- package/version.d.ts +2 -2
- package/version.js +2 -2
- package/version.js.map +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/mysql-core/session.ts"],"sourcesContent":["import { entityKind } from '~/entity.ts';\nimport { TransactionRollbackError } from '~/errors.ts';\nimport type { RelationalSchemaConfig, TablesRelationalConfig } from '~/relations.ts';\nimport { type Query, type SQL, sql } from '~/sql/sql.ts';\nimport type { Assume, Equal } from '~/utils.ts';\nimport { MySqlDatabase } from './db.ts';\nimport type { MySqlDialect } from './dialect.ts';\nimport type { SelectedFieldsOrdered } from './query-builders/select.types.ts';\n\nexport type Mode = 'default' | 'planetscale';\n\nexport interface MySqlQueryResultHKT {\n\treadonly $brand: 'MySqlQueryResultHKT';\n\treadonly row: unknown;\n\treadonly type: unknown;\n}\n\nexport interface AnyMySqlQueryResultHKT extends MySqlQueryResultHKT {\n\treadonly type: any;\n}\n\nexport type MySqlQueryResultKind<TKind extends MySqlQueryResultHKT, TRow> = (TKind & {\n\treadonly row: TRow;\n})['type'];\n\nexport interface MySqlPreparedQueryConfig {\n\texecute: unknown;\n\titerator: unknown;\n}\n\nexport interface MySqlPreparedQueryHKT {\n\treadonly $brand: 'MySqlPreparedQueryHKT';\n\treadonly config: unknown;\n\treadonly type: unknown;\n}\n\nexport type PreparedQueryKind<\n\tTKind extends MySqlPreparedQueryHKT,\n\tTConfig extends MySqlPreparedQueryConfig,\n\tTAssume extends boolean = false,\n> = Equal<TAssume, true> extends true\n\t? Assume<(TKind & { readonly config: TConfig })['type'], MySqlPreparedQuery<TConfig>>\n\t: (TKind & { readonly config: TConfig })['type'];\n\nexport abstract class MySqlPreparedQuery<T extends MySqlPreparedQueryConfig> {\n\tstatic readonly [entityKind]: string = 'MySqlPreparedQuery';\n\n\t/** @internal */\n\tjoinsNotNullableMap?: Record<string, boolean>;\n\n\tabstract execute(placeholderValues?: Record<string, unknown>): Promise<T['execute']>;\n\n\tabstract iterator(placeholderValues?: Record<string, unknown>): AsyncGenerator<T['iterator']>;\n}\n\nexport interface MySqlTransactionConfig {\n\twithConsistentSnapshot?: boolean;\n\taccessMode?: 'read only' | 'read write';\n\tisolationLevel: 'read uncommitted' | 'read committed' | 'repeatable read' | 'serializable';\n}\n\nexport abstract class MySqlSession<\n\tTQueryResult extends MySqlQueryResultHKT = MySqlQueryResultHKT,\n\tTPreparedQueryHKT extends PreparedQueryHKTBase = PreparedQueryHKTBase,\n\tTFullSchema extends Record<string, unknown> = Record<string, never>,\n\tTSchema extends TablesRelationalConfig = Record<string, never>,\n> {\n\tstatic readonly [entityKind]: string = 'MySqlSession';\n\n\tconstructor(protected dialect: MySqlDialect) {}\n\n\tabstract prepareQuery<T extends MySqlPreparedQueryConfig, TPreparedQueryHKT extends MySqlPreparedQueryHKT>(\n\t\tquery: Query,\n\t\tfields: SelectedFieldsOrdered | undefined,\n\t\tcustomResultMapper?: (rows: unknown[][]) => T['execute'],\n\t\tgeneratedIds?: Record<string, unknown>[],\n\t\treturningIds?: SelectedFieldsOrdered,\n\t): PreparedQueryKind<TPreparedQueryHKT, T>;\n\n\texecute<T>(query: SQL): Promise<T> {\n\t\treturn this.prepareQuery<MySqlPreparedQueryConfig & { execute: T }, PreparedQueryHKTBase>(\n\t\t\tthis.dialect.sqlToQuery(query),\n\t\t\tundefined,\n\t\t).execute();\n\t}\n\n\tabstract all<T = unknown>(query: SQL): Promise<T[]>;\n\n\tabstract transaction<T>(\n\t\ttransaction: (tx: MySqlTransaction<TQueryResult, TPreparedQueryHKT, TFullSchema, TSchema>) => Promise<T>,\n\t\tconfig?: MySqlTransactionConfig,\n\t): Promise<T>;\n\n\tprotected getSetTransactionSQL(config: MySqlTransactionConfig): SQL | undefined {\n\t\tconst parts: string[] = [];\n\n\t\tif (config.isolationLevel) {\n\t\t\tparts.push(`isolation level ${config.isolationLevel}`);\n\t\t}\n\n\t\treturn parts.length ? sql`set transaction ${sql.raw(parts.join(' '))}` : undefined;\n\t}\n\n\tprotected getStartTransactionSQL(config: MySqlTransactionConfig): SQL | undefined {\n\t\tconst parts: string[] = [];\n\n\t\tif (config.withConsistentSnapshot) {\n\t\t\tparts.push('with consistent snapshot');\n\t\t}\n\n\t\tif (config.accessMode) {\n\t\t\tparts.push(config.accessMode);\n\t\t}\n\n\t\treturn parts.length ? sql`start transaction ${sql.raw(parts.join(' '))}` : undefined;\n\t}\n}\n\nexport abstract class MySqlTransaction<\n\tTQueryResult extends MySqlQueryResultHKT,\n\tTPreparedQueryHKT extends PreparedQueryHKTBase,\n\tTFullSchema extends Record<string, unknown> = Record<string, never>,\n\tTSchema extends TablesRelationalConfig = Record<string, never>,\n> extends MySqlDatabase<TQueryResult, TPreparedQueryHKT, TFullSchema, TSchema> {\n\tstatic readonly [entityKind]: string = 'MySqlTransaction';\n\n\tconstructor(\n\t\tdialect: MySqlDialect,\n\t\tsession: MySqlSession,\n\t\tprotected schema: RelationalSchemaConfig<TSchema> | undefined,\n\t\tprotected readonly nestedIndex: number,\n\t\tmode: Mode,\n\t) {\n\t\tsuper(dialect, session, schema, mode);\n\t}\n\n\trollback(): never {\n\t\tthrow new TransactionRollbackError();\n\t}\n\n\t/** Nested transactions (aka savepoints) only work with InnoDB engine. */\n\tabstract override transaction<T>(\n\t\ttransaction: (tx: MySqlTransaction<TQueryResult, TPreparedQueryHKT, TFullSchema, TSchema>) => Promise<T>,\n\t): Promise<T>;\n}\n\nexport interface PreparedQueryHKTBase extends MySqlPreparedQueryHKT {\n\ttype: MySqlPreparedQuery<Assume<this['config'], MySqlPreparedQueryConfig>>;\n}\n"],"mappings":"AAAA,SAAS,kBAAkB;AAC3B,SAAS,gCAAgC;AAEzC,SAA+B,WAAW;AAE1C,SAAS,qBAAqB;AAuCvB,MAAe,mBAAuD;AAAA,EAC5E,QAAiB,UAAU,IAAY;AAAA;AAAA,EAGvC;AAKD;AAQO,MAAe,aAKpB;AAAA,EAGD,YAAsB,SAAuB;AAAvB;AAAA,EAAwB;AAAA,EAF9C,QAAiB,UAAU,IAAY;AAAA,EAYvC,QAAW,OAAwB;AAClC,WAAO,KAAK;AAAA,MACX,KAAK,QAAQ,WAAW,KAAK;AAAA,MAC7B;AAAA,IACD,EAAE,QAAQ;AAAA,EACX;AAAA,
|
|
1
|
+
{"version":3,"sources":["../../src/mysql-core/session.ts"],"sourcesContent":["import { entityKind } from '~/entity.ts';\nimport { TransactionRollbackError } from '~/errors.ts';\nimport type { RelationalSchemaConfig, TablesRelationalConfig } from '~/relations.ts';\nimport { type Query, type SQL, sql } from '~/sql/sql.ts';\nimport type { Assume, Equal } from '~/utils.ts';\nimport { MySqlDatabase } from './db.ts';\nimport type { MySqlDialect } from './dialect.ts';\nimport type { SelectedFieldsOrdered } from './query-builders/select.types.ts';\n\nexport type Mode = 'default' | 'planetscale';\n\nexport interface MySqlQueryResultHKT {\n\treadonly $brand: 'MySqlQueryResultHKT';\n\treadonly row: unknown;\n\treadonly type: unknown;\n}\n\nexport interface AnyMySqlQueryResultHKT extends MySqlQueryResultHKT {\n\treadonly type: any;\n}\n\nexport type MySqlQueryResultKind<TKind extends MySqlQueryResultHKT, TRow> = (TKind & {\n\treadonly row: TRow;\n})['type'];\n\nexport interface MySqlPreparedQueryConfig {\n\texecute: unknown;\n\titerator: unknown;\n}\n\nexport interface MySqlPreparedQueryHKT {\n\treadonly $brand: 'MySqlPreparedQueryHKT';\n\treadonly config: unknown;\n\treadonly type: unknown;\n}\n\nexport type PreparedQueryKind<\n\tTKind extends MySqlPreparedQueryHKT,\n\tTConfig extends MySqlPreparedQueryConfig,\n\tTAssume extends boolean = false,\n> = Equal<TAssume, true> extends true\n\t? Assume<(TKind & { readonly config: TConfig })['type'], MySqlPreparedQuery<TConfig>>\n\t: (TKind & { readonly config: TConfig })['type'];\n\nexport abstract class MySqlPreparedQuery<T extends MySqlPreparedQueryConfig> {\n\tstatic readonly [entityKind]: string = 'MySqlPreparedQuery';\n\n\t/** @internal */\n\tjoinsNotNullableMap?: Record<string, boolean>;\n\n\tabstract execute(placeholderValues?: Record<string, unknown>): Promise<T['execute']>;\n\n\tabstract iterator(placeholderValues?: Record<string, unknown>): AsyncGenerator<T['iterator']>;\n}\n\nexport interface MySqlTransactionConfig {\n\twithConsistentSnapshot?: boolean;\n\taccessMode?: 'read only' | 'read write';\n\tisolationLevel: 'read uncommitted' | 'read committed' | 'repeatable read' | 'serializable';\n}\n\nexport abstract class MySqlSession<\n\tTQueryResult extends MySqlQueryResultHKT = MySqlQueryResultHKT,\n\tTPreparedQueryHKT extends PreparedQueryHKTBase = PreparedQueryHKTBase,\n\tTFullSchema extends Record<string, unknown> = Record<string, never>,\n\tTSchema extends TablesRelationalConfig = Record<string, never>,\n> {\n\tstatic readonly [entityKind]: string = 'MySqlSession';\n\n\tconstructor(protected dialect: MySqlDialect) {}\n\n\tabstract prepareQuery<T extends MySqlPreparedQueryConfig, TPreparedQueryHKT extends MySqlPreparedQueryHKT>(\n\t\tquery: Query,\n\t\tfields: SelectedFieldsOrdered | undefined,\n\t\tcustomResultMapper?: (rows: unknown[][]) => T['execute'],\n\t\tgeneratedIds?: Record<string, unknown>[],\n\t\treturningIds?: SelectedFieldsOrdered,\n\t): PreparedQueryKind<TPreparedQueryHKT, T>;\n\n\texecute<T>(query: SQL): Promise<T> {\n\t\treturn this.prepareQuery<MySqlPreparedQueryConfig & { execute: T }, PreparedQueryHKTBase>(\n\t\t\tthis.dialect.sqlToQuery(query),\n\t\t\tundefined,\n\t\t).execute();\n\t}\n\n\tabstract all<T = unknown>(query: SQL): Promise<T[]>;\n\n\tasync count(sql: SQL): Promise<number> {\n\t\tconst res = await this.execute<[[{ count: string }]]>(sql);\n\n\t\treturn Number(\n\t\t\tres[0][0]['count'],\n\t\t);\n\t}\n\n\tabstract transaction<T>(\n\t\ttransaction: (tx: MySqlTransaction<TQueryResult, TPreparedQueryHKT, TFullSchema, TSchema>) => Promise<T>,\n\t\tconfig?: MySqlTransactionConfig,\n\t): Promise<T>;\n\n\tprotected getSetTransactionSQL(config: MySqlTransactionConfig): SQL | undefined {\n\t\tconst parts: string[] = [];\n\n\t\tif (config.isolationLevel) {\n\t\t\tparts.push(`isolation level ${config.isolationLevel}`);\n\t\t}\n\n\t\treturn parts.length ? sql`set transaction ${sql.raw(parts.join(' '))}` : undefined;\n\t}\n\n\tprotected getStartTransactionSQL(config: MySqlTransactionConfig): SQL | undefined {\n\t\tconst parts: string[] = [];\n\n\t\tif (config.withConsistentSnapshot) {\n\t\t\tparts.push('with consistent snapshot');\n\t\t}\n\n\t\tif (config.accessMode) {\n\t\t\tparts.push(config.accessMode);\n\t\t}\n\n\t\treturn parts.length ? sql`start transaction ${sql.raw(parts.join(' '))}` : undefined;\n\t}\n}\n\nexport abstract class MySqlTransaction<\n\tTQueryResult extends MySqlQueryResultHKT,\n\tTPreparedQueryHKT extends PreparedQueryHKTBase,\n\tTFullSchema extends Record<string, unknown> = Record<string, never>,\n\tTSchema extends TablesRelationalConfig = Record<string, never>,\n> extends MySqlDatabase<TQueryResult, TPreparedQueryHKT, TFullSchema, TSchema> {\n\tstatic readonly [entityKind]: string = 'MySqlTransaction';\n\n\tconstructor(\n\t\tdialect: MySqlDialect,\n\t\tsession: MySqlSession,\n\t\tprotected schema: RelationalSchemaConfig<TSchema> | undefined,\n\t\tprotected readonly nestedIndex: number,\n\t\tmode: Mode,\n\t) {\n\t\tsuper(dialect, session, schema, mode);\n\t}\n\n\trollback(): never {\n\t\tthrow new TransactionRollbackError();\n\t}\n\n\t/** Nested transactions (aka savepoints) only work with InnoDB engine. */\n\tabstract override transaction<T>(\n\t\ttransaction: (tx: MySqlTransaction<TQueryResult, TPreparedQueryHKT, TFullSchema, TSchema>) => Promise<T>,\n\t): Promise<T>;\n}\n\nexport interface PreparedQueryHKTBase extends MySqlPreparedQueryHKT {\n\ttype: MySqlPreparedQuery<Assume<this['config'], MySqlPreparedQueryConfig>>;\n}\n"],"mappings":"AAAA,SAAS,kBAAkB;AAC3B,SAAS,gCAAgC;AAEzC,SAA+B,WAAW;AAE1C,SAAS,qBAAqB;AAuCvB,MAAe,mBAAuD;AAAA,EAC5E,QAAiB,UAAU,IAAY;AAAA;AAAA,EAGvC;AAKD;AAQO,MAAe,aAKpB;AAAA,EAGD,YAAsB,SAAuB;AAAvB;AAAA,EAAwB;AAAA,EAF9C,QAAiB,UAAU,IAAY;AAAA,EAYvC,QAAW,OAAwB;AAClC,WAAO,KAAK;AAAA,MACX,KAAK,QAAQ,WAAW,KAAK;AAAA,MAC7B;AAAA,IACD,EAAE,QAAQ;AAAA,EACX;AAAA,EAIA,MAAM,MAAMA,MAA2B;AACtC,UAAM,MAAM,MAAM,KAAK,QAA+BA,IAAG;AAEzD,WAAO;AAAA,MACN,IAAI,CAAC,EAAE,CAAC,EAAE,OAAO;AAAA,IAClB;AAAA,EACD;AAAA,EAOU,qBAAqB,QAAiD;AAC/E,UAAM,QAAkB,CAAC;AAEzB,QAAI,OAAO,gBAAgB;AAC1B,YAAM,KAAK,mBAAmB,OAAO,cAAc,EAAE;AAAA,IACtD;AAEA,WAAO,MAAM,SAAS,sBAAsB,IAAI,IAAI,MAAM,KAAK,GAAG,CAAC,CAAC,KAAK;AAAA,EAC1E;AAAA,EAEU,uBAAuB,QAAiD;AACjF,UAAM,QAAkB,CAAC;AAEzB,QAAI,OAAO,wBAAwB;AAClC,YAAM,KAAK,0BAA0B;AAAA,IACtC;AAEA,QAAI,OAAO,YAAY;AACtB,YAAM,KAAK,OAAO,UAAU;AAAA,IAC7B;AAEA,WAAO,MAAM,SAAS,wBAAwB,IAAI,IAAI,MAAM,KAAK,GAAG,CAAC,CAAC,KAAK;AAAA,EAC5E;AACD;AAEO,MAAe,yBAKZ,cAAqE;AAAA,EAG9E,YACC,SACA,SACU,QACS,aACnB,MACC;AACD,UAAM,SAAS,SAAS,QAAQ,IAAI;AAJ1B;AACS;AAAA,EAIpB;AAAA,EAVA,QAAiB,UAAU,IAAY;AAAA,EAYvC,WAAkB;AACjB,UAAM,IAAI,yBAAyB;AAAA,EACpC;AAMD;","names":["sql"]}
|
package/mysql-proxy/driver.cjs
CHANGED
|
@@ -18,14 +18,19 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
19
|
var driver_exports = {};
|
|
20
20
|
__export(driver_exports, {
|
|
21
|
+
MySqlRemoteDatabase: () => MySqlRemoteDatabase,
|
|
21
22
|
drizzle: () => drizzle
|
|
22
23
|
});
|
|
23
24
|
module.exports = __toCommonJS(driver_exports);
|
|
25
|
+
var import_entity = require("../entity.cjs");
|
|
24
26
|
var import_logger = require("../logger.cjs");
|
|
25
27
|
var import_db = require("../mysql-core/db.cjs");
|
|
26
28
|
var import_dialect = require("../mysql-core/dialect.cjs");
|
|
27
29
|
var import_relations = require("../relations.cjs");
|
|
28
30
|
var import_session = require("./session.cjs");
|
|
31
|
+
class MySqlRemoteDatabase extends import_db.MySqlDatabase {
|
|
32
|
+
static [import_entity.entityKind] = "MySqlRemoteDatabase";
|
|
33
|
+
}
|
|
29
34
|
function drizzle(callback, config = {}) {
|
|
30
35
|
const dialect = new import_dialect.MySqlDialect();
|
|
31
36
|
let logger;
|
|
@@ -47,10 +52,11 @@ function drizzle(callback, config = {}) {
|
|
|
47
52
|
};
|
|
48
53
|
}
|
|
49
54
|
const session = new import_session.MySqlRemoteSession(callback, dialect, schema, { logger });
|
|
50
|
-
return new
|
|
55
|
+
return new MySqlRemoteDatabase(dialect, session, schema, "default");
|
|
51
56
|
}
|
|
52
57
|
// Annotate the CommonJS export names for ESM import in node:
|
|
53
58
|
0 && (module.exports = {
|
|
59
|
+
MySqlRemoteDatabase,
|
|
54
60
|
drizzle
|
|
55
61
|
});
|
|
56
62
|
//# sourceMappingURL=driver.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/mysql-proxy/driver.ts"],"sourcesContent":["import { DefaultLogger } from '~/logger.ts';\nimport { MySqlDatabase } from '~/mysql-core/db.ts';\nimport { MySqlDialect } from '~/mysql-core/dialect.ts';\nimport {\n\tcreateTableRelationsHelpers,\n\textractTablesRelationalConfig,\n\ttype RelationalSchemaConfig,\n\ttype TablesRelationalConfig,\n} from '~/relations.ts';\nimport type { DrizzleConfig } from '~/utils.ts';\nimport { type MySqlRemotePreparedQueryHKT, type MySqlRemoteQueryResultHKT, MySqlRemoteSession } from './session.ts';\n\nexport
|
|
1
|
+
{"version":3,"sources":["../../src/mysql-proxy/driver.ts"],"sourcesContent":["import { entityKind } from '~/entity.ts';\nimport { DefaultLogger } from '~/logger.ts';\nimport { MySqlDatabase } from '~/mysql-core/db.ts';\nimport { MySqlDialect } from '~/mysql-core/dialect.ts';\nimport {\n\tcreateTableRelationsHelpers,\n\textractTablesRelationalConfig,\n\ttype RelationalSchemaConfig,\n\ttype TablesRelationalConfig,\n} from '~/relations.ts';\nimport type { DrizzleConfig } from '~/utils.ts';\nimport { type MySqlRemotePreparedQueryHKT, type MySqlRemoteQueryResultHKT, MySqlRemoteSession } from './session.ts';\n\nexport class MySqlRemoteDatabase<\n\tTSchema extends Record<string, unknown> = Record<string, never>,\n> extends MySqlDatabase<MySqlRemoteQueryResultHKT, MySqlRemotePreparedQueryHKT, TSchema> {\n\tstatic readonly [entityKind]: string = 'MySqlRemoteDatabase';\n}\n\nexport type RemoteCallback = (\n\tsql: string,\n\tparams: any[],\n\tmethod: 'all' | 'execute',\n) => Promise<{ rows: any[]; insertId?: number; affectedRows?: number }>;\n\nexport function drizzle<TSchema extends Record<string, unknown> = Record<string, never>>(\n\tcallback: RemoteCallback,\n\tconfig: DrizzleConfig<TSchema> = {},\n): MySqlRemoteDatabase<TSchema> {\n\tconst dialect = new MySqlDialect();\n\tlet logger;\n\tif (config.logger === true) {\n\t\tlogger = new DefaultLogger();\n\t} else if (config.logger !== false) {\n\t\tlogger = config.logger;\n\t}\n\n\tlet schema: RelationalSchemaConfig<TablesRelationalConfig> | undefined;\n\tif (config.schema) {\n\t\tconst tablesConfig = extractTablesRelationalConfig(\n\t\t\tconfig.schema,\n\t\t\tcreateTableRelationsHelpers,\n\t\t);\n\t\tschema = {\n\t\t\tfullSchema: config.schema,\n\t\t\tschema: tablesConfig.tables,\n\t\t\ttableNamesMap: tablesConfig.tableNamesMap,\n\t\t};\n\t}\n\n\tconst session = new MySqlRemoteSession(callback, dialect, schema, { logger });\n\treturn new MySqlRemoteDatabase(dialect, session, schema as any, 'default') as MySqlRemoteDatabase<TSchema>;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAA2B;AAC3B,oBAA8B;AAC9B,gBAA8B;AAC9B,qBAA6B;AAC7B,uBAKO;AAEP,qBAAqG;AAE9F,MAAM,4BAEH,wBAA+E;AAAA,EACxF,QAAiB,wBAAU,IAAY;AACxC;AAQO,SAAS,QACf,UACA,SAAiC,CAAC,GACH;AAC/B,QAAM,UAAU,IAAI,4BAAa;AACjC,MAAI;AACJ,MAAI,OAAO,WAAW,MAAM;AAC3B,aAAS,IAAI,4BAAc;AAAA,EAC5B,WAAW,OAAO,WAAW,OAAO;AACnC,aAAS,OAAO;AAAA,EACjB;AAEA,MAAI;AACJ,MAAI,OAAO,QAAQ;AAClB,UAAM,mBAAe;AAAA,MACpB,OAAO;AAAA,MACP;AAAA,IACD;AACA,aAAS;AAAA,MACR,YAAY,OAAO;AAAA,MACnB,QAAQ,aAAa;AAAA,MACrB,eAAe,aAAa;AAAA,IAC7B;AAAA,EACD;AAEA,QAAM,UAAU,IAAI,kCAAmB,UAAU,SAAS,QAAQ,EAAE,OAAO,CAAC;AAC5E,SAAO,IAAI,oBAAoB,SAAS,SAAS,QAAe,SAAS;AAC1E;","names":[]}
|
package/mysql-proxy/driver.d.cts
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
|
+
import { entityKind } from "../entity.cjs";
|
|
1
2
|
import { MySqlDatabase } from "../mysql-core/db.cjs";
|
|
2
3
|
import type { DrizzleConfig } from "../utils.cjs";
|
|
3
4
|
import { type MySqlRemotePreparedQueryHKT, type MySqlRemoteQueryResultHKT } from "./session.cjs";
|
|
4
|
-
export
|
|
5
|
+
export declare class MySqlRemoteDatabase<TSchema extends Record<string, unknown> = Record<string, never>> extends MySqlDatabase<MySqlRemoteQueryResultHKT, MySqlRemotePreparedQueryHKT, TSchema> {
|
|
6
|
+
static readonly [entityKind]: string;
|
|
7
|
+
}
|
|
5
8
|
export type RemoteCallback = (sql: string, params: any[], method: 'all' | 'execute') => Promise<{
|
|
6
9
|
rows: any[];
|
|
7
10
|
insertId?: number;
|
package/mysql-proxy/driver.d.ts
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
|
+
import { entityKind } from "../entity.js";
|
|
1
2
|
import { MySqlDatabase } from "../mysql-core/db.js";
|
|
2
3
|
import type { DrizzleConfig } from "../utils.js";
|
|
3
4
|
import { type MySqlRemotePreparedQueryHKT, type MySqlRemoteQueryResultHKT } from "./session.js";
|
|
4
|
-
export
|
|
5
|
+
export declare class MySqlRemoteDatabase<TSchema extends Record<string, unknown> = Record<string, never>> extends MySqlDatabase<MySqlRemoteQueryResultHKT, MySqlRemotePreparedQueryHKT, TSchema> {
|
|
6
|
+
static readonly [entityKind]: string;
|
|
7
|
+
}
|
|
5
8
|
export type RemoteCallback = (sql: string, params: any[], method: 'all' | 'execute') => Promise<{
|
|
6
9
|
rows: any[];
|
|
7
10
|
insertId?: number;
|
package/mysql-proxy/driver.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { entityKind } from "../entity.js";
|
|
1
2
|
import { DefaultLogger } from "../logger.js";
|
|
2
3
|
import { MySqlDatabase } from "../mysql-core/db.js";
|
|
3
4
|
import { MySqlDialect } from "../mysql-core/dialect.js";
|
|
@@ -6,6 +7,9 @@ import {
|
|
|
6
7
|
extractTablesRelationalConfig
|
|
7
8
|
} from "../relations.js";
|
|
8
9
|
import { MySqlRemoteSession } from "./session.js";
|
|
10
|
+
class MySqlRemoteDatabase extends MySqlDatabase {
|
|
11
|
+
static [entityKind] = "MySqlRemoteDatabase";
|
|
12
|
+
}
|
|
9
13
|
function drizzle(callback, config = {}) {
|
|
10
14
|
const dialect = new MySqlDialect();
|
|
11
15
|
let logger;
|
|
@@ -27,9 +31,10 @@ function drizzle(callback, config = {}) {
|
|
|
27
31
|
};
|
|
28
32
|
}
|
|
29
33
|
const session = new MySqlRemoteSession(callback, dialect, schema, { logger });
|
|
30
|
-
return new
|
|
34
|
+
return new MySqlRemoteDatabase(dialect, session, schema, "default");
|
|
31
35
|
}
|
|
32
36
|
export {
|
|
37
|
+
MySqlRemoteDatabase,
|
|
33
38
|
drizzle
|
|
34
39
|
};
|
|
35
40
|
//# sourceMappingURL=driver.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/mysql-proxy/driver.ts"],"sourcesContent":["import { DefaultLogger } from '~/logger.ts';\nimport { MySqlDatabase } from '~/mysql-core/db.ts';\nimport { MySqlDialect } from '~/mysql-core/dialect.ts';\nimport {\n\tcreateTableRelationsHelpers,\n\textractTablesRelationalConfig,\n\ttype RelationalSchemaConfig,\n\ttype TablesRelationalConfig,\n} from '~/relations.ts';\nimport type { DrizzleConfig } from '~/utils.ts';\nimport { type MySqlRemotePreparedQueryHKT, type MySqlRemoteQueryResultHKT, MySqlRemoteSession } from './session.ts';\n\nexport
|
|
1
|
+
{"version":3,"sources":["../../src/mysql-proxy/driver.ts"],"sourcesContent":["import { entityKind } from '~/entity.ts';\nimport { DefaultLogger } from '~/logger.ts';\nimport { MySqlDatabase } from '~/mysql-core/db.ts';\nimport { MySqlDialect } from '~/mysql-core/dialect.ts';\nimport {\n\tcreateTableRelationsHelpers,\n\textractTablesRelationalConfig,\n\ttype RelationalSchemaConfig,\n\ttype TablesRelationalConfig,\n} from '~/relations.ts';\nimport type { DrizzleConfig } from '~/utils.ts';\nimport { type MySqlRemotePreparedQueryHKT, type MySqlRemoteQueryResultHKT, MySqlRemoteSession } from './session.ts';\n\nexport class MySqlRemoteDatabase<\n\tTSchema extends Record<string, unknown> = Record<string, never>,\n> extends MySqlDatabase<MySqlRemoteQueryResultHKT, MySqlRemotePreparedQueryHKT, TSchema> {\n\tstatic readonly [entityKind]: string = 'MySqlRemoteDatabase';\n}\n\nexport type RemoteCallback = (\n\tsql: string,\n\tparams: any[],\n\tmethod: 'all' | 'execute',\n) => Promise<{ rows: any[]; insertId?: number; affectedRows?: number }>;\n\nexport function drizzle<TSchema extends Record<string, unknown> = Record<string, never>>(\n\tcallback: RemoteCallback,\n\tconfig: DrizzleConfig<TSchema> = {},\n): MySqlRemoteDatabase<TSchema> {\n\tconst dialect = new MySqlDialect();\n\tlet logger;\n\tif (config.logger === true) {\n\t\tlogger = new DefaultLogger();\n\t} else if (config.logger !== false) {\n\t\tlogger = config.logger;\n\t}\n\n\tlet schema: RelationalSchemaConfig<TablesRelationalConfig> | undefined;\n\tif (config.schema) {\n\t\tconst tablesConfig = extractTablesRelationalConfig(\n\t\t\tconfig.schema,\n\t\t\tcreateTableRelationsHelpers,\n\t\t);\n\t\tschema = {\n\t\t\tfullSchema: config.schema,\n\t\t\tschema: tablesConfig.tables,\n\t\t\ttableNamesMap: tablesConfig.tableNamesMap,\n\t\t};\n\t}\n\n\tconst session = new MySqlRemoteSession(callback, dialect, schema, { logger });\n\treturn new MySqlRemoteDatabase(dialect, session, schema as any, 'default') as MySqlRemoteDatabase<TSchema>;\n}\n"],"mappings":"AAAA,SAAS,kBAAkB;AAC3B,SAAS,qBAAqB;AAC9B,SAAS,qBAAqB;AAC9B,SAAS,oBAAoB;AAC7B;AAAA,EACC;AAAA,EACA;AAAA,OAGM;AAEP,SAA2E,0BAA0B;AAE9F,MAAM,4BAEH,cAA+E;AAAA,EACxF,QAAiB,UAAU,IAAY;AACxC;AAQO,SAAS,QACf,UACA,SAAiC,CAAC,GACH;AAC/B,QAAM,UAAU,IAAI,aAAa;AACjC,MAAI;AACJ,MAAI,OAAO,WAAW,MAAM;AAC3B,aAAS,IAAI,cAAc;AAAA,EAC5B,WAAW,OAAO,WAAW,OAAO;AACnC,aAAS,OAAO;AAAA,EACjB;AAEA,MAAI;AACJ,MAAI,OAAO,QAAQ;AAClB,UAAM,eAAe;AAAA,MACpB,OAAO;AAAA,MACP;AAAA,IACD;AACA,aAAS;AAAA,MACR,YAAY,OAAO;AAAA,MACnB,QAAQ,aAAa;AAAA,MACrB,eAAe,aAAa;AAAA,IAC7B;AAAA,EACD;AAEA,QAAM,UAAU,IAAI,mBAAmB,UAAU,SAAS,QAAQ,EAAE,OAAO,CAAC;AAC5E,SAAO,IAAI,oBAAoB,SAAS,SAAS,QAAe,SAAS;AAC1E;","names":[]}
|
package/mysql2/driver.cjs
CHANGED
|
@@ -18,6 +18,7 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
19
|
var driver_exports = {};
|
|
20
20
|
__export(driver_exports, {
|
|
21
|
+
MySql2Database: () => MySql2Database,
|
|
21
22
|
MySql2Driver: () => MySql2Driver,
|
|
22
23
|
MySqlDatabase: () => import_db2.MySqlDatabase,
|
|
23
24
|
drizzle: () => drizzle
|
|
@@ -42,6 +43,9 @@ class MySql2Driver {
|
|
|
42
43
|
return new import_session.MySql2Session(this.client, this.dialect, schema, { logger: this.options.logger, mode });
|
|
43
44
|
}
|
|
44
45
|
}
|
|
46
|
+
class MySql2Database extends import_db.MySqlDatabase {
|
|
47
|
+
static [import_entity.entityKind] = "MySql2Database";
|
|
48
|
+
}
|
|
45
49
|
function drizzle(client, config = {}) {
|
|
46
50
|
const dialect = new import_dialect.MySqlDialect();
|
|
47
51
|
let logger;
|
|
@@ -73,13 +77,14 @@ function drizzle(client, config = {}) {
|
|
|
73
77
|
const mode = config.mode ?? "default";
|
|
74
78
|
const driver = new MySql2Driver(client, dialect, { logger });
|
|
75
79
|
const session = driver.createSession(schema, mode);
|
|
76
|
-
return new
|
|
80
|
+
return new MySql2Database(dialect, session, schema, mode);
|
|
77
81
|
}
|
|
78
82
|
function isCallbackClient(client) {
|
|
79
83
|
return typeof client.promise === "function";
|
|
80
84
|
}
|
|
81
85
|
// Annotate the CommonJS export names for ESM import in node:
|
|
82
86
|
0 && (module.exports = {
|
|
87
|
+
MySql2Database,
|
|
83
88
|
MySql2Driver,
|
|
84
89
|
MySqlDatabase,
|
|
85
90
|
drizzle
|
package/mysql2/driver.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/mysql2/driver.ts"],"sourcesContent":["import type { Connection as CallbackConnection, Pool as CallbackPool } from 'mysql2';\nimport { entityKind } from '~/entity.ts';\nimport type { Logger } from '~/logger.ts';\nimport { DefaultLogger } from '~/logger.ts';\nimport { MySqlDatabase } from '~/mysql-core/db.ts';\nimport { MySqlDialect } from '~/mysql-core/dialect.ts';\nimport type { Mode } from '~/mysql-core/session.ts';\nimport {\n\tcreateTableRelationsHelpers,\n\textractTablesRelationalConfig,\n\ttype RelationalSchemaConfig,\n\ttype TablesRelationalConfig,\n} from '~/relations.ts';\nimport type { DrizzleConfig } from '~/utils.ts';\nimport { DrizzleError } from '../index.ts';\nimport type { MySql2Client, MySql2PreparedQueryHKT, MySql2QueryResultHKT } from './session.ts';\nimport { MySql2Session } from './session.ts';\n\nexport interface MySqlDriverOptions {\n\tlogger?: Logger;\n}\n\nexport class MySql2Driver {\n\tstatic readonly [entityKind]: string = 'MySql2Driver';\n\n\tconstructor(\n\t\tprivate client: MySql2Client,\n\t\tprivate dialect: MySqlDialect,\n\t\tprivate options: MySqlDriverOptions = {},\n\t) {\n\t}\n\n\tcreateSession(\n\t\tschema: RelationalSchemaConfig<TablesRelationalConfig> | undefined,\n\t\tmode: Mode,\n\t): MySql2Session<Record<string, unknown>, TablesRelationalConfig> {\n\t\treturn new MySql2Session(this.client, this.dialect, schema, { logger: this.options.logger, mode });\n\t}\n}\n\nexport { MySqlDatabase } from '~/mysql-core/db.ts';\n\nexport
|
|
1
|
+
{"version":3,"sources":["../../src/mysql2/driver.ts"],"sourcesContent":["import type { Connection as CallbackConnection, Pool as CallbackPool } from 'mysql2';\nimport { entityKind } from '~/entity.ts';\nimport type { Logger } from '~/logger.ts';\nimport { DefaultLogger } from '~/logger.ts';\nimport { MySqlDatabase } from '~/mysql-core/db.ts';\nimport { MySqlDialect } from '~/mysql-core/dialect.ts';\nimport type { Mode } from '~/mysql-core/session.ts';\nimport {\n\tcreateTableRelationsHelpers,\n\textractTablesRelationalConfig,\n\ttype RelationalSchemaConfig,\n\ttype TablesRelationalConfig,\n} from '~/relations.ts';\nimport type { DrizzleConfig } from '~/utils.ts';\nimport { DrizzleError } from '../index.ts';\nimport type { MySql2Client, MySql2PreparedQueryHKT, MySql2QueryResultHKT } from './session.ts';\nimport { MySql2Session } from './session.ts';\n\nexport interface MySqlDriverOptions {\n\tlogger?: Logger;\n}\n\nexport class MySql2Driver {\n\tstatic readonly [entityKind]: string = 'MySql2Driver';\n\n\tconstructor(\n\t\tprivate client: MySql2Client,\n\t\tprivate dialect: MySqlDialect,\n\t\tprivate options: MySqlDriverOptions = {},\n\t) {\n\t}\n\n\tcreateSession(\n\t\tschema: RelationalSchemaConfig<TablesRelationalConfig> | undefined,\n\t\tmode: Mode,\n\t): MySql2Session<Record<string, unknown>, TablesRelationalConfig> {\n\t\treturn new MySql2Session(this.client, this.dialect, schema, { logger: this.options.logger, mode });\n\t}\n}\n\nexport { MySqlDatabase } from '~/mysql-core/db.ts';\n\nexport class MySql2Database<\n\tTSchema extends Record<string, unknown> = Record<string, never>,\n> extends MySqlDatabase<MySql2QueryResultHKT, MySql2PreparedQueryHKT, TSchema> {\n\tstatic readonly [entityKind]: string = 'MySql2Database';\n}\n\nexport type MySql2DrizzleConfig<TSchema extends Record<string, unknown> = Record<string, never>> =\n\t& Omit<DrizzleConfig<TSchema>, 'schema'>\n\t& ({ schema: TSchema; mode: Mode } | { schema?: undefined; mode?: Mode });\n\nexport function drizzle<TSchema extends Record<string, unknown> = Record<string, never>>(\n\tclient: MySql2Client | CallbackConnection | CallbackPool,\n\tconfig: MySql2DrizzleConfig<TSchema> = {},\n): MySql2Database<TSchema> {\n\tconst dialect = new MySqlDialect();\n\tlet logger;\n\tif (config.logger === true) {\n\t\tlogger = new DefaultLogger();\n\t} else if (config.logger !== false) {\n\t\tlogger = config.logger;\n\t}\n\tif (isCallbackClient(client)) {\n\t\tclient = client.promise();\n\t}\n\n\tlet schema: RelationalSchemaConfig<TablesRelationalConfig> | undefined;\n\tif (config.schema) {\n\t\tif (config.mode === undefined) {\n\t\t\tthrow new DrizzleError({\n\t\t\t\tmessage:\n\t\t\t\t\t'You need to specify \"mode\": \"planetscale\" or \"default\" when providing a schema. Read more: https://orm.drizzle.team/docs/rqb#modes',\n\t\t\t});\n\t\t}\n\n\t\tconst tablesConfig = extractTablesRelationalConfig(\n\t\t\tconfig.schema,\n\t\t\tcreateTableRelationsHelpers,\n\t\t);\n\t\tschema = {\n\t\t\tfullSchema: config.schema,\n\t\t\tschema: tablesConfig.tables,\n\t\t\ttableNamesMap: tablesConfig.tableNamesMap,\n\t\t};\n\t}\n\n\tconst mode = config.mode ?? 'default';\n\n\tconst driver = new MySql2Driver(client as MySql2Client, dialect, { logger });\n\tconst session = driver.createSession(schema, mode);\n\treturn new MySql2Database(dialect, session, schema as any, mode) as MySql2Database<TSchema>;\n}\n\ninterface CallbackClient {\n\tpromise(): MySql2Client;\n}\n\nfunction isCallbackClient(client: any): client is CallbackClient {\n\treturn typeof client.promise === 'function';\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,oBAA2B;AAE3B,oBAA8B;AAC9B,gBAA8B;AAC9B,qBAA6B;AAE7B,uBAKO;AAEP,eAA6B;AAE7B,qBAA8B;AAwB9B,IAAAA,aAA8B;AAlBvB,MAAM,aAAa;AAAA,EAGzB,YACS,QACA,SACA,UAA8B,CAAC,GACtC;AAHO;AACA;AACA;AAAA,EAET;AAAA,EAPA,QAAiB,wBAAU,IAAY;AAAA,EASvC,cACC,QACA,MACiE;AACjE,WAAO,IAAI,6BAAc,KAAK,QAAQ,KAAK,SAAS,QAAQ,EAAE,QAAQ,KAAK,QAAQ,QAAQ,KAAK,CAAC;AAAA,EAClG;AACD;AAIO,MAAM,uBAEH,wBAAqE;AAAA,EAC9E,QAAiB,wBAAU,IAAY;AACxC;AAMO,SAAS,QACf,QACA,SAAuC,CAAC,GACd;AAC1B,QAAM,UAAU,IAAI,4BAAa;AACjC,MAAI;AACJ,MAAI,OAAO,WAAW,MAAM;AAC3B,aAAS,IAAI,4BAAc;AAAA,EAC5B,WAAW,OAAO,WAAW,OAAO;AACnC,aAAS,OAAO;AAAA,EACjB;AACA,MAAI,iBAAiB,MAAM,GAAG;AAC7B,aAAS,OAAO,QAAQ;AAAA,EACzB;AAEA,MAAI;AACJ,MAAI,OAAO,QAAQ;AAClB,QAAI,OAAO,SAAS,QAAW;AAC9B,YAAM,IAAI,sBAAa;AAAA,QACtB,SACC;AAAA,MACF,CAAC;AAAA,IACF;AAEA,UAAM,mBAAe;AAAA,MACpB,OAAO;AAAA,MACP;AAAA,IACD;AACA,aAAS;AAAA,MACR,YAAY,OAAO;AAAA,MACnB,QAAQ,aAAa;AAAA,MACrB,eAAe,aAAa;AAAA,IAC7B;AAAA,EACD;AAEA,QAAM,OAAO,OAAO,QAAQ;AAE5B,QAAM,SAAS,IAAI,aAAa,QAAwB,SAAS,EAAE,OAAO,CAAC;AAC3E,QAAM,UAAU,OAAO,cAAc,QAAQ,IAAI;AACjD,SAAO,IAAI,eAAe,SAAS,SAAS,QAAe,IAAI;AAChE;AAMA,SAAS,iBAAiB,QAAuC;AAChE,SAAO,OAAO,OAAO,YAAY;AAClC;","names":["import_db"]}
|
package/mysql2/driver.d.cts
CHANGED
|
@@ -20,7 +20,9 @@ export declare class MySql2Driver {
|
|
|
20
20
|
createSession(schema: RelationalSchemaConfig<TablesRelationalConfig> | undefined, mode: Mode): MySql2Session<Record<string, unknown>, TablesRelationalConfig>;
|
|
21
21
|
}
|
|
22
22
|
export { MySqlDatabase } from "../mysql-core/db.cjs";
|
|
23
|
-
export
|
|
23
|
+
export declare class MySql2Database<TSchema extends Record<string, unknown> = Record<string, never>> extends MySqlDatabase<MySql2QueryResultHKT, MySql2PreparedQueryHKT, TSchema> {
|
|
24
|
+
static readonly [entityKind]: string;
|
|
25
|
+
}
|
|
24
26
|
export type MySql2DrizzleConfig<TSchema extends Record<string, unknown> = Record<string, never>> = Omit<DrizzleConfig<TSchema>, 'schema'> & ({
|
|
25
27
|
schema: TSchema;
|
|
26
28
|
mode: Mode;
|
package/mysql2/driver.d.ts
CHANGED
|
@@ -20,7 +20,9 @@ export declare class MySql2Driver {
|
|
|
20
20
|
createSession(schema: RelationalSchemaConfig<TablesRelationalConfig> | undefined, mode: Mode): MySql2Session<Record<string, unknown>, TablesRelationalConfig>;
|
|
21
21
|
}
|
|
22
22
|
export { MySqlDatabase } from "../mysql-core/db.js";
|
|
23
|
-
export
|
|
23
|
+
export declare class MySql2Database<TSchema extends Record<string, unknown> = Record<string, never>> extends MySqlDatabase<MySql2QueryResultHKT, MySql2PreparedQueryHKT, TSchema> {
|
|
24
|
+
static readonly [entityKind]: string;
|
|
25
|
+
}
|
|
24
26
|
export type MySql2DrizzleConfig<TSchema extends Record<string, unknown> = Record<string, never>> = Omit<DrizzleConfig<TSchema>, 'schema'> & ({
|
|
25
27
|
schema: TSchema;
|
|
26
28
|
mode: Mode;
|
package/mysql2/driver.js
CHANGED
|
@@ -20,6 +20,9 @@ class MySql2Driver {
|
|
|
20
20
|
}
|
|
21
21
|
}
|
|
22
22
|
import { MySqlDatabase as MySqlDatabase2 } from "../mysql-core/db.js";
|
|
23
|
+
class MySql2Database extends MySqlDatabase {
|
|
24
|
+
static [entityKind] = "MySql2Database";
|
|
25
|
+
}
|
|
23
26
|
function drizzle(client, config = {}) {
|
|
24
27
|
const dialect = new MySqlDialect();
|
|
25
28
|
let logger;
|
|
@@ -51,12 +54,13 @@ function drizzle(client, config = {}) {
|
|
|
51
54
|
const mode = config.mode ?? "default";
|
|
52
55
|
const driver = new MySql2Driver(client, dialect, { logger });
|
|
53
56
|
const session = driver.createSession(schema, mode);
|
|
54
|
-
return new
|
|
57
|
+
return new MySql2Database(dialect, session, schema, mode);
|
|
55
58
|
}
|
|
56
59
|
function isCallbackClient(client) {
|
|
57
60
|
return typeof client.promise === "function";
|
|
58
61
|
}
|
|
59
62
|
export {
|
|
63
|
+
MySql2Database,
|
|
60
64
|
MySql2Driver,
|
|
61
65
|
MySqlDatabase2 as MySqlDatabase,
|
|
62
66
|
drizzle
|
package/mysql2/driver.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/mysql2/driver.ts"],"sourcesContent":["import type { Connection as CallbackConnection, Pool as CallbackPool } from 'mysql2';\nimport { entityKind } from '~/entity.ts';\nimport type { Logger } from '~/logger.ts';\nimport { DefaultLogger } from '~/logger.ts';\nimport { MySqlDatabase } from '~/mysql-core/db.ts';\nimport { MySqlDialect } from '~/mysql-core/dialect.ts';\nimport type { Mode } from '~/mysql-core/session.ts';\nimport {\n\tcreateTableRelationsHelpers,\n\textractTablesRelationalConfig,\n\ttype RelationalSchemaConfig,\n\ttype TablesRelationalConfig,\n} from '~/relations.ts';\nimport type { DrizzleConfig } from '~/utils.ts';\nimport { DrizzleError } from '../index.ts';\nimport type { MySql2Client, MySql2PreparedQueryHKT, MySql2QueryResultHKT } from './session.ts';\nimport { MySql2Session } from './session.ts';\n\nexport interface MySqlDriverOptions {\n\tlogger?: Logger;\n}\n\nexport class MySql2Driver {\n\tstatic readonly [entityKind]: string = 'MySql2Driver';\n\n\tconstructor(\n\t\tprivate client: MySql2Client,\n\t\tprivate dialect: MySqlDialect,\n\t\tprivate options: MySqlDriverOptions = {},\n\t) {\n\t}\n\n\tcreateSession(\n\t\tschema: RelationalSchemaConfig<TablesRelationalConfig> | undefined,\n\t\tmode: Mode,\n\t): MySql2Session<Record<string, unknown>, TablesRelationalConfig> {\n\t\treturn new MySql2Session(this.client, this.dialect, schema, { logger: this.options.logger, mode });\n\t}\n}\n\nexport { MySqlDatabase } from '~/mysql-core/db.ts';\n\nexport
|
|
1
|
+
{"version":3,"sources":["../../src/mysql2/driver.ts"],"sourcesContent":["import type { Connection as CallbackConnection, Pool as CallbackPool } from 'mysql2';\nimport { entityKind } from '~/entity.ts';\nimport type { Logger } from '~/logger.ts';\nimport { DefaultLogger } from '~/logger.ts';\nimport { MySqlDatabase } from '~/mysql-core/db.ts';\nimport { MySqlDialect } from '~/mysql-core/dialect.ts';\nimport type { Mode } from '~/mysql-core/session.ts';\nimport {\n\tcreateTableRelationsHelpers,\n\textractTablesRelationalConfig,\n\ttype RelationalSchemaConfig,\n\ttype TablesRelationalConfig,\n} from '~/relations.ts';\nimport type { DrizzleConfig } from '~/utils.ts';\nimport { DrizzleError } from '../index.ts';\nimport type { MySql2Client, MySql2PreparedQueryHKT, MySql2QueryResultHKT } from './session.ts';\nimport { MySql2Session } from './session.ts';\n\nexport interface MySqlDriverOptions {\n\tlogger?: Logger;\n}\n\nexport class MySql2Driver {\n\tstatic readonly [entityKind]: string = 'MySql2Driver';\n\n\tconstructor(\n\t\tprivate client: MySql2Client,\n\t\tprivate dialect: MySqlDialect,\n\t\tprivate options: MySqlDriverOptions = {},\n\t) {\n\t}\n\n\tcreateSession(\n\t\tschema: RelationalSchemaConfig<TablesRelationalConfig> | undefined,\n\t\tmode: Mode,\n\t): MySql2Session<Record<string, unknown>, TablesRelationalConfig> {\n\t\treturn new MySql2Session(this.client, this.dialect, schema, { logger: this.options.logger, mode });\n\t}\n}\n\nexport { MySqlDatabase } from '~/mysql-core/db.ts';\n\nexport class MySql2Database<\n\tTSchema extends Record<string, unknown> = Record<string, never>,\n> extends MySqlDatabase<MySql2QueryResultHKT, MySql2PreparedQueryHKT, TSchema> {\n\tstatic readonly [entityKind]: string = 'MySql2Database';\n}\n\nexport type MySql2DrizzleConfig<TSchema extends Record<string, unknown> = Record<string, never>> =\n\t& Omit<DrizzleConfig<TSchema>, 'schema'>\n\t& ({ schema: TSchema; mode: Mode } | { schema?: undefined; mode?: Mode });\n\nexport function drizzle<TSchema extends Record<string, unknown> = Record<string, never>>(\n\tclient: MySql2Client | CallbackConnection | CallbackPool,\n\tconfig: MySql2DrizzleConfig<TSchema> = {},\n): MySql2Database<TSchema> {\n\tconst dialect = new MySqlDialect();\n\tlet logger;\n\tif (config.logger === true) {\n\t\tlogger = new DefaultLogger();\n\t} else if (config.logger !== false) {\n\t\tlogger = config.logger;\n\t}\n\tif (isCallbackClient(client)) {\n\t\tclient = client.promise();\n\t}\n\n\tlet schema: RelationalSchemaConfig<TablesRelationalConfig> | undefined;\n\tif (config.schema) {\n\t\tif (config.mode === undefined) {\n\t\t\tthrow new DrizzleError({\n\t\t\t\tmessage:\n\t\t\t\t\t'You need to specify \"mode\": \"planetscale\" or \"default\" when providing a schema. Read more: https://orm.drizzle.team/docs/rqb#modes',\n\t\t\t});\n\t\t}\n\n\t\tconst tablesConfig = extractTablesRelationalConfig(\n\t\t\tconfig.schema,\n\t\t\tcreateTableRelationsHelpers,\n\t\t);\n\t\tschema = {\n\t\t\tfullSchema: config.schema,\n\t\t\tschema: tablesConfig.tables,\n\t\t\ttableNamesMap: tablesConfig.tableNamesMap,\n\t\t};\n\t}\n\n\tconst mode = config.mode ?? 'default';\n\n\tconst driver = new MySql2Driver(client as MySql2Client, dialect, { logger });\n\tconst session = driver.createSession(schema, mode);\n\treturn new MySql2Database(dialect, session, schema as any, mode) as MySql2Database<TSchema>;\n}\n\ninterface CallbackClient {\n\tpromise(): MySql2Client;\n}\n\nfunction isCallbackClient(client: any): client is CallbackClient {\n\treturn typeof client.promise === 'function';\n}\n"],"mappings":"AACA,SAAS,kBAAkB;AAE3B,SAAS,qBAAqB;AAC9B,SAAS,qBAAqB;AAC9B,SAAS,oBAAoB;AAE7B;AAAA,EACC;AAAA,EACA;AAAA,OAGM;AAEP,SAAS,oBAAoB;AAE7B,SAAS,qBAAqB;AAMvB,MAAM,aAAa;AAAA,EAGzB,YACS,QACA,SACA,UAA8B,CAAC,GACtC;AAHO;AACA;AACA;AAAA,EAET;AAAA,EAPA,QAAiB,UAAU,IAAY;AAAA,EASvC,cACC,QACA,MACiE;AACjE,WAAO,IAAI,cAAc,KAAK,QAAQ,KAAK,SAAS,QAAQ,EAAE,QAAQ,KAAK,QAAQ,QAAQ,KAAK,CAAC;AAAA,EAClG;AACD;AAEA,SAAS,iBAAAA,sBAAqB;AAEvB,MAAM,uBAEH,cAAqE;AAAA,EAC9E,QAAiB,UAAU,IAAY;AACxC;AAMO,SAAS,QACf,QACA,SAAuC,CAAC,GACd;AAC1B,QAAM,UAAU,IAAI,aAAa;AACjC,MAAI;AACJ,MAAI,OAAO,WAAW,MAAM;AAC3B,aAAS,IAAI,cAAc;AAAA,EAC5B,WAAW,OAAO,WAAW,OAAO;AACnC,aAAS,OAAO;AAAA,EACjB;AACA,MAAI,iBAAiB,MAAM,GAAG;AAC7B,aAAS,OAAO,QAAQ;AAAA,EACzB;AAEA,MAAI;AACJ,MAAI,OAAO,QAAQ;AAClB,QAAI,OAAO,SAAS,QAAW;AAC9B,YAAM,IAAI,aAAa;AAAA,QACtB,SACC;AAAA,MACF,CAAC;AAAA,IACF;AAEA,UAAM,eAAe;AAAA,MACpB,OAAO;AAAA,MACP;AAAA,IACD;AACA,aAAS;AAAA,MACR,YAAY,OAAO;AAAA,MACnB,QAAQ,aAAa;AAAA,MACrB,eAAe,aAAa;AAAA,IAC7B;AAAA,EACD;AAEA,QAAM,OAAO,OAAO,QAAQ;AAE5B,QAAM,SAAS,IAAI,aAAa,QAAwB,SAAS,EAAE,OAAO,CAAC;AAC3E,QAAM,UAAU,OAAO,cAAc,QAAQ,IAAI;AACjD,SAAO,IAAI,eAAe,SAAS,SAAS,QAAe,IAAI;AAChE;AAMA,SAAS,iBAAiB,QAAuC;AAChE,SAAO,OAAO,OAAO,YAAY;AAClC;","names":["MySqlDatabase"]}
|
package/mysql2/migrator.cjs
CHANGED
|
@@ -24,7 +24,10 @@ module.exports = __toCommonJS(migrator_exports);
|
|
|
24
24
|
var import_migrator = require("../migrator.cjs");
|
|
25
25
|
async function migrate(db, config) {
|
|
26
26
|
const migrations = (0, import_migrator.readMigrationFiles)(config);
|
|
27
|
-
|
|
27
|
+
const preparedConfig = typeof config === "string" ? {
|
|
28
|
+
migrationsFolder: config
|
|
29
|
+
} : config;
|
|
30
|
+
await db.dialect.migrate(migrations, db.session, preparedConfig);
|
|
28
31
|
}
|
|
29
32
|
// Annotate the CommonJS export names for ESM import in node:
|
|
30
33
|
0 && (module.exports = {
|
package/mysql2/migrator.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/mysql2/migrator.ts"],"sourcesContent":["import type { MigrationConfig } from '~/migrator.ts';\nimport { readMigrationFiles } from '~/migrator.ts';\nimport type { MySql2Database } from './driver.ts';\n\nexport async function migrate<TSchema extends Record<string, unknown>>(\n\tdb: MySql2Database<TSchema>,\n\tconfig: MigrationConfig,\n) {\n\tconst migrations = readMigrationFiles(config);\n\tawait db.dialect.migrate(migrations, db.session,
|
|
1
|
+
{"version":3,"sources":["../../src/mysql2/migrator.ts"],"sourcesContent":["import type { MigrationConfig } from '~/migrator.ts';\nimport { readMigrationFiles } from '~/migrator.ts';\nimport type { MySql2Database } from './driver.ts';\n\nexport async function migrate<TSchema extends Record<string, unknown>>(\n\tdb: MySql2Database<TSchema>,\n\tconfig: MigrationConfig | string,\n) {\n\tconst migrations = readMigrationFiles(config);\n\n\tconst preparedConfig = typeof config === 'string'\n\t\t? {\n\t\t\tmigrationsFolder: config,\n\t\t}\n\t\t: config;\n\n\tawait db.dialect.migrate(migrations, db.session, preparedConfig);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,sBAAmC;AAGnC,eAAsB,QACrB,IACA,QACC;AACD,QAAM,iBAAa,oCAAmB,MAAM;AAE5C,QAAM,iBAAiB,OAAO,WAAW,WACtC;AAAA,IACD,kBAAkB;AAAA,EACnB,IACE;AAEH,QAAM,GAAG,QAAQ,QAAQ,YAAY,GAAG,SAAS,cAAc;AAChE;","names":[]}
|
package/mysql2/migrator.d.cts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { MigrationConfig } from "../migrator.cjs";
|
|
2
2
|
import type { MySql2Database } from "./driver.cjs";
|
|
3
|
-
export declare function migrate<TSchema extends Record<string, unknown>>(db: MySql2Database<TSchema>, config: MigrationConfig): Promise<void>;
|
|
3
|
+
export declare function migrate<TSchema extends Record<string, unknown>>(db: MySql2Database<TSchema>, config: MigrationConfig | string): Promise<void>;
|
package/mysql2/migrator.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { MigrationConfig } from "../migrator.js";
|
|
2
2
|
import type { MySql2Database } from "./driver.js";
|
|
3
|
-
export declare function migrate<TSchema extends Record<string, unknown>>(db: MySql2Database<TSchema>, config: MigrationConfig): Promise<void>;
|
|
3
|
+
export declare function migrate<TSchema extends Record<string, unknown>>(db: MySql2Database<TSchema>, config: MigrationConfig | string): Promise<void>;
|
package/mysql2/migrator.js
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import { readMigrationFiles } from "../migrator.js";
|
|
2
2
|
async function migrate(db, config) {
|
|
3
3
|
const migrations = readMigrationFiles(config);
|
|
4
|
-
|
|
4
|
+
const preparedConfig = typeof config === "string" ? {
|
|
5
|
+
migrationsFolder: config
|
|
6
|
+
} : config;
|
|
7
|
+
await db.dialect.migrate(migrations, db.session, preparedConfig);
|
|
5
8
|
}
|
|
6
9
|
export {
|
|
7
10
|
migrate
|
package/mysql2/migrator.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/mysql2/migrator.ts"],"sourcesContent":["import type { MigrationConfig } from '~/migrator.ts';\nimport { readMigrationFiles } from '~/migrator.ts';\nimport type { MySql2Database } from './driver.ts';\n\nexport async function migrate<TSchema extends Record<string, unknown>>(\n\tdb: MySql2Database<TSchema>,\n\tconfig: MigrationConfig,\n) {\n\tconst migrations = readMigrationFiles(config);\n\tawait db.dialect.migrate(migrations, db.session,
|
|
1
|
+
{"version":3,"sources":["../../src/mysql2/migrator.ts"],"sourcesContent":["import type { MigrationConfig } from '~/migrator.ts';\nimport { readMigrationFiles } from '~/migrator.ts';\nimport type { MySql2Database } from './driver.ts';\n\nexport async function migrate<TSchema extends Record<string, unknown>>(\n\tdb: MySql2Database<TSchema>,\n\tconfig: MigrationConfig | string,\n) {\n\tconst migrations = readMigrationFiles(config);\n\n\tconst preparedConfig = typeof config === 'string'\n\t\t? {\n\t\t\tmigrationsFolder: config,\n\t\t}\n\t\t: config;\n\n\tawait db.dialect.migrate(migrations, db.session, preparedConfig);\n}\n"],"mappings":"AACA,SAAS,0BAA0B;AAGnC,eAAsB,QACrB,IACA,QACC;AACD,QAAM,aAAa,mBAAmB,MAAM;AAE5C,QAAM,iBAAiB,OAAO,WAAW,WACtC;AAAA,IACD,kBAAkB;AAAA,EACnB,IACE;AAEH,QAAM,GAAG,QAAQ,QAAQ,YAAY,GAAG,SAAS,cAAc;AAChE;","names":[]}
|
package/neon/index.cjs
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __copyProps = (to, from, except, desc) => {
|
|
7
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
+
for (let key of __getOwnPropNames(from))
|
|
9
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
+
}
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
15
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
16
|
+
var neon_exports = {};
|
|
17
|
+
module.exports = __toCommonJS(neon_exports);
|
|
18
|
+
__reExport(neon_exports, require("./rls.cjs"), module.exports);
|
|
19
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
20
|
+
0 && (module.exports = {
|
|
21
|
+
...require("./rls.cjs")
|
|
22
|
+
});
|
|
23
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/neon/index.ts"],"sourcesContent":["export * from './rls.ts';\n"],"mappings":";;;;;;;;;;;;;;;AAAA;AAAA;AAAA,yBAAc,qBAAd;","names":[]}
|
package/neon/index.d.cts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./rls.cjs";
|
package/neon/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./rls.js";
|
package/neon/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/neon/index.ts"],"sourcesContent":["export * from './rls.ts';\n"],"mappings":"AAAA,cAAc;","names":[]}
|
package/neon/rls.cjs
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var rls_exports = {};
|
|
20
|
+
__export(rls_exports, {
|
|
21
|
+
anonymousRole: () => anonymousRole,
|
|
22
|
+
authUid: () => authUid,
|
|
23
|
+
authenticatedRole: () => authenticatedRole,
|
|
24
|
+
crudPolicy: () => crudPolicy
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(rls_exports);
|
|
27
|
+
var import_entity = require("../entity.cjs");
|
|
28
|
+
var import_pg_core = require("../pg-core/index.cjs");
|
|
29
|
+
var import_sql = require("../sql/sql.cjs");
|
|
30
|
+
const crudPolicy = (options) => {
|
|
31
|
+
const read = options.read === true ? import_sql.sql`select true` : options.read === false || options.read === void 0 ? import_sql.sql`select false` : options.read;
|
|
32
|
+
const modify = options.modify === true ? import_sql.sql`select true` : options.modify === false || options.modify === void 0 ? import_sql.sql`select false` : options.modify;
|
|
33
|
+
let rolesName = "";
|
|
34
|
+
if (Array.isArray(options.role)) {
|
|
35
|
+
rolesName = options.role.map((it) => {
|
|
36
|
+
return (0, import_entity.is)(it, import_pg_core.PgRole) ? it.name : it;
|
|
37
|
+
}).join("-");
|
|
38
|
+
} else {
|
|
39
|
+
rolesName = (0, import_entity.is)(options.role, import_pg_core.PgRole) ? options.role.name : options.role;
|
|
40
|
+
}
|
|
41
|
+
return {
|
|
42
|
+
// Important to have "_drizzle_internal" prefix for any key here. Right after we will make
|
|
43
|
+
// 3rd param in table as an array - we will move it to array and use ... operator
|
|
44
|
+
// We can't use table name here, because in examples you can specify several crudPolicies on one table
|
|
45
|
+
// So we need some other way to have a unique name
|
|
46
|
+
[`_drizzle_internal-${rolesName}-crud-policy-insert`]: (0, import_pg_core.pgPolicy)(`crud-${rolesName}-policy-insert`, {
|
|
47
|
+
for: "insert",
|
|
48
|
+
to: options.role,
|
|
49
|
+
using: modify,
|
|
50
|
+
withCheck: modify
|
|
51
|
+
}),
|
|
52
|
+
[`_drizzle_internal-${rolesName}-crud-policy-update`]: (0, import_pg_core.pgPolicy)(`crud-${rolesName}-policy-update`, {
|
|
53
|
+
for: "update",
|
|
54
|
+
to: options.role,
|
|
55
|
+
using: modify,
|
|
56
|
+
withCheck: modify
|
|
57
|
+
}),
|
|
58
|
+
[`_drizzle_internal-${rolesName}-crud-policy-delete`]: (0, import_pg_core.pgPolicy)(`crud-${rolesName}-policy-delete`, {
|
|
59
|
+
for: "delete",
|
|
60
|
+
to: options.role,
|
|
61
|
+
using: modify,
|
|
62
|
+
withCheck: modify
|
|
63
|
+
}),
|
|
64
|
+
[`_drizzle_internal-${rolesName}-crud-policy-select`]: (0, import_pg_core.pgPolicy)(`crud-${rolesName}-policy-select`, {
|
|
65
|
+
for: "select",
|
|
66
|
+
to: options.role,
|
|
67
|
+
using: read
|
|
68
|
+
})
|
|
69
|
+
};
|
|
70
|
+
};
|
|
71
|
+
const authenticatedRole = (0, import_pg_core.pgRole)("authenticated").existing();
|
|
72
|
+
const anonymousRole = (0, import_pg_core.pgRole)("anonymous").existing();
|
|
73
|
+
const authUid = (userIdColumn) => import_sql.sql`select auth.user_id() = ${userIdColumn}`;
|
|
74
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
75
|
+
0 && (module.exports = {
|
|
76
|
+
anonymousRole,
|
|
77
|
+
authUid,
|
|
78
|
+
authenticatedRole,
|
|
79
|
+
crudPolicy
|
|
80
|
+
});
|
|
81
|
+
//# sourceMappingURL=rls.cjs.map
|
package/neon/rls.cjs.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/neon/rls.ts"],"sourcesContent":["import { is } from '~/entity.ts';\nimport { pgPolicy, PgRole, pgRole } from '~/pg-core/index.ts';\nimport type { AnyPgColumn, PgPolicyToOption } from '~/pg-core/index.ts';\nimport { type SQL, sql } from '~/sql/sql.ts';\n\nexport const crudPolicy = (\n\toptions: {\n\t\trole: PgPolicyToOption;\n\t\tread?: SQL | boolean;\n\t\tmodify?: SQL | boolean;\n\t},\n) => {\n\tconst read: SQL = options.read === true\n\t\t? sql`select true`\n\t\t: options.read === false || options.read === undefined\n\t\t? sql`select false`\n\t\t: options.read;\n\n\tconst modify: SQL = options.modify === true\n\t\t? sql`select true`\n\t\t: options.modify === false || options.modify === undefined\n\t\t? sql`select false`\n\t\t: options.modify;\n\n\tlet rolesName = '';\n\tif (Array.isArray(options.role)) {\n\t\trolesName = options.role.map((it) => {\n\t\t\treturn is(it, PgRole) ? it.name : it as string;\n\t\t}).join('-');\n\t} else {\n\t\trolesName = is(options.role, PgRole) ? options.role.name : options.role as string;\n\t}\n\n\t// Return the modify policy, followed by the read policy.\n\treturn {\n\t\t// Important to have \"_drizzle_internal\" prefix for any key here. Right after we will make\n\t\t// 3rd param in table as an array - we will move it to array and use ... operator\n\n\t\t// We can't use table name here, because in examples you can specify several crudPolicies on one table\n\t\t// So we need some other way to have a unique name\n\t\t[`_drizzle_internal-${rolesName}-crud-policy-insert`]: pgPolicy(`crud-${rolesName}-policy-insert`, {\n\t\t\tfor: 'insert',\n\t\t\tto: options.role,\n\t\t\tusing: modify,\n\t\t\twithCheck: modify,\n\t\t}),\n\t\t[`_drizzle_internal-${rolesName}-crud-policy-update`]: pgPolicy(`crud-${rolesName}-policy-update`, {\n\t\t\tfor: 'update',\n\t\t\tto: options.role,\n\t\t\tusing: modify,\n\t\t\twithCheck: modify,\n\t\t}),\n\t\t[`_drizzle_internal-${rolesName}-crud-policy-delete`]: pgPolicy(`crud-${rolesName}-policy-delete`, {\n\t\t\tfor: 'delete',\n\t\t\tto: options.role,\n\t\t\tusing: modify,\n\t\t\twithCheck: modify,\n\t\t}),\n\t\t[`_drizzle_internal-${rolesName}-crud-policy-select`]: pgPolicy(`crud-${rolesName}-policy-select`, {\n\t\t\tfor: 'select',\n\t\t\tto: options.role,\n\t\t\tusing: read,\n\t\t}),\n\t};\n};\n\n// These are default roles that Neon will set up.\nexport const authenticatedRole = pgRole('authenticated').existing();\nexport const anonymousRole = pgRole('anonymous').existing();\n\nexport const authUid = (userIdColumn: AnyPgColumn) => sql`select auth.user_id() = ${userIdColumn}`;\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAAmB;AACnB,qBAAyC;AAEzC,iBAA8B;AAEvB,MAAM,aAAa,CACzB,YAKI;AACJ,QAAM,OAAY,QAAQ,SAAS,OAChC,8BACA,QAAQ,SAAS,SAAS,QAAQ,SAAS,SAC3C,+BACA,QAAQ;AAEX,QAAM,SAAc,QAAQ,WAAW,OACpC,8BACA,QAAQ,WAAW,SAAS,QAAQ,WAAW,SAC/C,+BACA,QAAQ;AAEX,MAAI,YAAY;AAChB,MAAI,MAAM,QAAQ,QAAQ,IAAI,GAAG;AAChC,gBAAY,QAAQ,KAAK,IAAI,CAAC,OAAO;AACpC,iBAAO,kBAAG,IAAI,qBAAM,IAAI,GAAG,OAAO;AAAA,IACnC,CAAC,EAAE,KAAK,GAAG;AAAA,EACZ,OAAO;AACN,oBAAY,kBAAG,QAAQ,MAAM,qBAAM,IAAI,QAAQ,KAAK,OAAO,QAAQ;AAAA,EACpE;AAGA,SAAO;AAAA;AAAA;AAAA;AAAA;AAAA,IAMN,CAAC,qBAAqB,SAAS,qBAAqB,OAAG,yBAAS,QAAQ,SAAS,kBAAkB;AAAA,MAClG,KAAK;AAAA,MACL,IAAI,QAAQ;AAAA,MACZ,OAAO;AAAA,MACP,WAAW;AAAA,IACZ,CAAC;AAAA,IACD,CAAC,qBAAqB,SAAS,qBAAqB,OAAG,yBAAS,QAAQ,SAAS,kBAAkB;AAAA,MAClG,KAAK;AAAA,MACL,IAAI,QAAQ;AAAA,MACZ,OAAO;AAAA,MACP,WAAW;AAAA,IACZ,CAAC;AAAA,IACD,CAAC,qBAAqB,SAAS,qBAAqB,OAAG,yBAAS,QAAQ,SAAS,kBAAkB;AAAA,MAClG,KAAK;AAAA,MACL,IAAI,QAAQ;AAAA,MACZ,OAAO;AAAA,MACP,WAAW;AAAA,IACZ,CAAC;AAAA,IACD,CAAC,qBAAqB,SAAS,qBAAqB,OAAG,yBAAS,QAAQ,SAAS,kBAAkB;AAAA,MAClG,KAAK;AAAA,MACL,IAAI,QAAQ;AAAA,MACZ,OAAO;AAAA,IACR,CAAC;AAAA,EACF;AACD;AAGO,MAAM,wBAAoB,uBAAO,eAAe,EAAE,SAAS;AAC3D,MAAM,oBAAgB,uBAAO,WAAW,EAAE,SAAS;AAEnD,MAAM,UAAU,CAAC,iBAA8B,yCAA8B,YAAY;","names":[]}
|
package/neon/rls.d.cts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { PgRole } from "../pg-core/index.cjs";
|
|
2
|
+
import type { AnyPgColumn, PgPolicyToOption } from "../pg-core/index.cjs";
|
|
3
|
+
import { type SQL } from "../sql/sql.cjs";
|
|
4
|
+
export declare const crudPolicy: (options: {
|
|
5
|
+
role: PgPolicyToOption;
|
|
6
|
+
read?: SQL | boolean;
|
|
7
|
+
modify?: SQL | boolean;
|
|
8
|
+
}) => {
|
|
9
|
+
[x: string]: import("../pg-core/index.ts").PgPolicy;
|
|
10
|
+
};
|
|
11
|
+
export declare const authenticatedRole: PgRole;
|
|
12
|
+
export declare const anonymousRole: PgRole;
|
|
13
|
+
export declare const authUid: (userIdColumn: AnyPgColumn) => SQL<unknown>;
|
package/neon/rls.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { PgRole } from "../pg-core/index.js";
|
|
2
|
+
import type { AnyPgColumn, PgPolicyToOption } from "../pg-core/index.js";
|
|
3
|
+
import { type SQL } from "../sql/sql.js";
|
|
4
|
+
export declare const crudPolicy: (options: {
|
|
5
|
+
role: PgPolicyToOption;
|
|
6
|
+
read?: SQL | boolean;
|
|
7
|
+
modify?: SQL | boolean;
|
|
8
|
+
}) => {
|
|
9
|
+
[x: string]: import("../pg-core/index.js").PgPolicy;
|
|
10
|
+
};
|
|
11
|
+
export declare const authenticatedRole: PgRole;
|
|
12
|
+
export declare const anonymousRole: PgRole;
|
|
13
|
+
export declare const authUid: (userIdColumn: AnyPgColumn) => SQL<unknown>;
|
package/neon/rls.js
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { is } from "../entity.js";
|
|
2
|
+
import { pgPolicy, PgRole, pgRole } from "../pg-core/index.js";
|
|
3
|
+
import { sql } from "../sql/sql.js";
|
|
4
|
+
const crudPolicy = (options) => {
|
|
5
|
+
const read = options.read === true ? sql`select true` : options.read === false || options.read === void 0 ? sql`select false` : options.read;
|
|
6
|
+
const modify = options.modify === true ? sql`select true` : options.modify === false || options.modify === void 0 ? sql`select false` : options.modify;
|
|
7
|
+
let rolesName = "";
|
|
8
|
+
if (Array.isArray(options.role)) {
|
|
9
|
+
rolesName = options.role.map((it) => {
|
|
10
|
+
return is(it, PgRole) ? it.name : it;
|
|
11
|
+
}).join("-");
|
|
12
|
+
} else {
|
|
13
|
+
rolesName = is(options.role, PgRole) ? options.role.name : options.role;
|
|
14
|
+
}
|
|
15
|
+
return {
|
|
16
|
+
// Important to have "_drizzle_internal" prefix for any key here. Right after we will make
|
|
17
|
+
// 3rd param in table as an array - we will move it to array and use ... operator
|
|
18
|
+
// We can't use table name here, because in examples you can specify several crudPolicies on one table
|
|
19
|
+
// So we need some other way to have a unique name
|
|
20
|
+
[`_drizzle_internal-${rolesName}-crud-policy-insert`]: pgPolicy(`crud-${rolesName}-policy-insert`, {
|
|
21
|
+
for: "insert",
|
|
22
|
+
to: options.role,
|
|
23
|
+
using: modify,
|
|
24
|
+
withCheck: modify
|
|
25
|
+
}),
|
|
26
|
+
[`_drizzle_internal-${rolesName}-crud-policy-update`]: pgPolicy(`crud-${rolesName}-policy-update`, {
|
|
27
|
+
for: "update",
|
|
28
|
+
to: options.role,
|
|
29
|
+
using: modify,
|
|
30
|
+
withCheck: modify
|
|
31
|
+
}),
|
|
32
|
+
[`_drizzle_internal-${rolesName}-crud-policy-delete`]: pgPolicy(`crud-${rolesName}-policy-delete`, {
|
|
33
|
+
for: "delete",
|
|
34
|
+
to: options.role,
|
|
35
|
+
using: modify,
|
|
36
|
+
withCheck: modify
|
|
37
|
+
}),
|
|
38
|
+
[`_drizzle_internal-${rolesName}-crud-policy-select`]: pgPolicy(`crud-${rolesName}-policy-select`, {
|
|
39
|
+
for: "select",
|
|
40
|
+
to: options.role,
|
|
41
|
+
using: read
|
|
42
|
+
})
|
|
43
|
+
};
|
|
44
|
+
};
|
|
45
|
+
const authenticatedRole = pgRole("authenticated").existing();
|
|
46
|
+
const anonymousRole = pgRole("anonymous").existing();
|
|
47
|
+
const authUid = (userIdColumn) => sql`select auth.user_id() = ${userIdColumn}`;
|
|
48
|
+
export {
|
|
49
|
+
anonymousRole,
|
|
50
|
+
authUid,
|
|
51
|
+
authenticatedRole,
|
|
52
|
+
crudPolicy
|
|
53
|
+
};
|
|
54
|
+
//# sourceMappingURL=rls.js.map
|
package/neon/rls.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/neon/rls.ts"],"sourcesContent":["import { is } from '~/entity.ts';\nimport { pgPolicy, PgRole, pgRole } from '~/pg-core/index.ts';\nimport type { AnyPgColumn, PgPolicyToOption } from '~/pg-core/index.ts';\nimport { type SQL, sql } from '~/sql/sql.ts';\n\nexport const crudPolicy = (\n\toptions: {\n\t\trole: PgPolicyToOption;\n\t\tread?: SQL | boolean;\n\t\tmodify?: SQL | boolean;\n\t},\n) => {\n\tconst read: SQL = options.read === true\n\t\t? sql`select true`\n\t\t: options.read === false || options.read === undefined\n\t\t? sql`select false`\n\t\t: options.read;\n\n\tconst modify: SQL = options.modify === true\n\t\t? sql`select true`\n\t\t: options.modify === false || options.modify === undefined\n\t\t? sql`select false`\n\t\t: options.modify;\n\n\tlet rolesName = '';\n\tif (Array.isArray(options.role)) {\n\t\trolesName = options.role.map((it) => {\n\t\t\treturn is(it, PgRole) ? it.name : it as string;\n\t\t}).join('-');\n\t} else {\n\t\trolesName = is(options.role, PgRole) ? options.role.name : options.role as string;\n\t}\n\n\t// Return the modify policy, followed by the read policy.\n\treturn {\n\t\t// Important to have \"_drizzle_internal\" prefix for any key here. Right after we will make\n\t\t// 3rd param in table as an array - we will move it to array and use ... operator\n\n\t\t// We can't use table name here, because in examples you can specify several crudPolicies on one table\n\t\t// So we need some other way to have a unique name\n\t\t[`_drizzle_internal-${rolesName}-crud-policy-insert`]: pgPolicy(`crud-${rolesName}-policy-insert`, {\n\t\t\tfor: 'insert',\n\t\t\tto: options.role,\n\t\t\tusing: modify,\n\t\t\twithCheck: modify,\n\t\t}),\n\t\t[`_drizzle_internal-${rolesName}-crud-policy-update`]: pgPolicy(`crud-${rolesName}-policy-update`, {\n\t\t\tfor: 'update',\n\t\t\tto: options.role,\n\t\t\tusing: modify,\n\t\t\twithCheck: modify,\n\t\t}),\n\t\t[`_drizzle_internal-${rolesName}-crud-policy-delete`]: pgPolicy(`crud-${rolesName}-policy-delete`, {\n\t\t\tfor: 'delete',\n\t\t\tto: options.role,\n\t\t\tusing: modify,\n\t\t\twithCheck: modify,\n\t\t}),\n\t\t[`_drizzle_internal-${rolesName}-crud-policy-select`]: pgPolicy(`crud-${rolesName}-policy-select`, {\n\t\t\tfor: 'select',\n\t\t\tto: options.role,\n\t\t\tusing: read,\n\t\t}),\n\t};\n};\n\n// These are default roles that Neon will set up.\nexport const authenticatedRole = pgRole('authenticated').existing();\nexport const anonymousRole = pgRole('anonymous').existing();\n\nexport const authUid = (userIdColumn: AnyPgColumn) => sql`select auth.user_id() = ${userIdColumn}`;\n"],"mappings":"AAAA,SAAS,UAAU;AACnB,SAAS,UAAU,QAAQ,cAAc;AAEzC,SAAmB,WAAW;AAEvB,MAAM,aAAa,CACzB,YAKI;AACJ,QAAM,OAAY,QAAQ,SAAS,OAChC,mBACA,QAAQ,SAAS,SAAS,QAAQ,SAAS,SAC3C,oBACA,QAAQ;AAEX,QAAM,SAAc,QAAQ,WAAW,OACpC,mBACA,QAAQ,WAAW,SAAS,QAAQ,WAAW,SAC/C,oBACA,QAAQ;AAEX,MAAI,YAAY;AAChB,MAAI,MAAM,QAAQ,QAAQ,IAAI,GAAG;AAChC,gBAAY,QAAQ,KAAK,IAAI,CAAC,OAAO;AACpC,aAAO,GAAG,IAAI,MAAM,IAAI,GAAG,OAAO;AAAA,IACnC,CAAC,EAAE,KAAK,GAAG;AAAA,EACZ,OAAO;AACN,gBAAY,GAAG,QAAQ,MAAM,MAAM,IAAI,QAAQ,KAAK,OAAO,QAAQ;AAAA,EACpE;AAGA,SAAO;AAAA;AAAA;AAAA;AAAA;AAAA,IAMN,CAAC,qBAAqB,SAAS,qBAAqB,GAAG,SAAS,QAAQ,SAAS,kBAAkB;AAAA,MAClG,KAAK;AAAA,MACL,IAAI,QAAQ;AAAA,MACZ,OAAO;AAAA,MACP,WAAW;AAAA,IACZ,CAAC;AAAA,IACD,CAAC,qBAAqB,SAAS,qBAAqB,GAAG,SAAS,QAAQ,SAAS,kBAAkB;AAAA,MAClG,KAAK;AAAA,MACL,IAAI,QAAQ;AAAA,MACZ,OAAO;AAAA,MACP,WAAW;AAAA,IACZ,CAAC;AAAA,IACD,CAAC,qBAAqB,SAAS,qBAAqB,GAAG,SAAS,QAAQ,SAAS,kBAAkB;AAAA,MAClG,KAAK;AAAA,MACL,IAAI,QAAQ;AAAA,MACZ,OAAO;AAAA,MACP,WAAW;AAAA,IACZ,CAAC;AAAA,IACD,CAAC,qBAAqB,SAAS,qBAAqB,GAAG,SAAS,QAAQ,SAAS,kBAAkB;AAAA,MAClG,KAAK;AAAA,MACL,IAAI,QAAQ;AAAA,MACZ,OAAO;AAAA,IACR,CAAC;AAAA,EACF;AACD;AAGO,MAAM,oBAAoB,OAAO,eAAe,EAAE,SAAS;AAC3D,MAAM,gBAAgB,OAAO,WAAW,EAAE,SAAS;AAEnD,MAAM,UAAU,CAAC,iBAA8B,8BAA8B,YAAY;","names":[]}
|
package/neon-http/session.cjs
CHANGED
|
@@ -129,6 +129,12 @@ class NeonHttpSession extends import_session.PgSession {
|
|
|
129
129
|
async queryObjects(query, params) {
|
|
130
130
|
return this.client(query, params, { arrayMode: false, fullResults: true });
|
|
131
131
|
}
|
|
132
|
+
async count(sql) {
|
|
133
|
+
const res = await this.execute(sql);
|
|
134
|
+
return Number(
|
|
135
|
+
res["rows"][0]["count"]
|
|
136
|
+
);
|
|
137
|
+
}
|
|
132
138
|
async transaction(_transaction, _config = {}) {
|
|
133
139
|
throw new Error("No transactions support in neon-http driver");
|
|
134
140
|
}
|