@remix-run/data-table-postgres 0.4.0 → 0.5.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 +40 -16
- package/dist/index.d.ts +3 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/lib/database.d.ts +35 -0
- package/dist/lib/database.d.ts.map +1 -0
- package/dist/lib/database.js +31 -0
- package/dist/lib/{adapter.d.ts → driver.d.ts} +40 -38
- package/dist/lib/driver.d.ts.map +1 -0
- package/dist/lib/driver.js +577 -0
- package/dist/lib/sql-compiler.d.ts +2 -1
- package/dist/lib/sql-compiler.d.ts.map +1 -1
- package/dist/lib/sql-compiler.js +6 -6
- package/package.json +12 -12
- package/src/index.ts +3 -1
- package/src/lib/database.ts +45 -0
- package/src/lib/driver.ts +760 -0
- package/src/lib/sql-compiler.ts +8 -7
- package/dist/lib/adapter.d.ts.map +0 -1
- package/dist/lib/adapter.js +0 -343
- package/src/lib/adapter.ts +0 -454
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { Database, type DatabaseOptions } from '@remix-run/data-table'
|
|
2
|
+
|
|
3
|
+
import { PostgresDatabaseDriver, type PostgresDatabaseInput } from './driver.ts'
|
|
4
|
+
|
|
5
|
+
/** Options for creating a PostgreSQL database. */
|
|
6
|
+
export interface PostgresDatabaseOptions extends DatabaseOptions {
|
|
7
|
+
/** Database used while dropping and recreating the configured database (`postgres` by default). */
|
|
8
|
+
maintenanceDatabase?: string
|
|
9
|
+
/** Template used to recreate the configured database (`template0` by default). */
|
|
10
|
+
template?: string
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/** A {@link Database} backed by PostgreSQL. */
|
|
14
|
+
export class PostgresDatabase extends Database<'postgres'> {
|
|
15
|
+
/**
|
|
16
|
+
* Creates a PostgreSQL-backed database.
|
|
17
|
+
* @param input PostgreSQL pool configuration, pool, or client.
|
|
18
|
+
* @param options Database runtime and recreation options.
|
|
19
|
+
*/
|
|
20
|
+
constructor(input: PostgresDatabaseInput, options: PostgresDatabaseOptions = {}) {
|
|
21
|
+
super(new PostgresDatabaseDriver(input, options), options)
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Creates a PostgreSQL-backed database.
|
|
27
|
+
*
|
|
28
|
+
* @param input PostgreSQL pool configuration, pool, or client.
|
|
29
|
+
* @param options Database runtime and recreation options.
|
|
30
|
+
* @returns A PostgreSQL database.
|
|
31
|
+
* @example
|
|
32
|
+
* ```ts
|
|
33
|
+
* import { createPostgresDatabase } from 'remix/data-table/postgres'
|
|
34
|
+
*
|
|
35
|
+
* let db = createPostgresDatabase({
|
|
36
|
+
* connectionString: process.env.DATABASE_URL,
|
|
37
|
+
* })
|
|
38
|
+
* ```
|
|
39
|
+
*/
|
|
40
|
+
export function createPostgresDatabase(
|
|
41
|
+
input: PostgresDatabaseInput,
|
|
42
|
+
options: PostgresDatabaseOptions = {},
|
|
43
|
+
): PostgresDatabase {
|
|
44
|
+
return new PostgresDatabase(input, options)
|
|
45
|
+
}
|