@remix-run/data-table-mysql 0.3.1 → 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.
@@ -0,0 +1,46 @@
1
+ import { Database, type DatabaseOptions } from '@remix-run/data-table'
2
+
3
+ import { MysqlDatabaseDriver, type MysqlDatabaseInput } from './driver.ts'
4
+
5
+ /** Options for creating a MySQL database. */
6
+ export interface MysqlDatabaseOptions extends DatabaseOptions {
7
+ /** Character set assigned to the recreated database. */
8
+ characterSet?: string
9
+ /** Collation assigned to the recreated database. */
10
+ collation?: string
11
+ }
12
+
13
+ /** A {@link Database} backed by MySQL. */
14
+ export class MysqlDatabase extends Database<'mysql'> {
15
+ /**
16
+ * Creates a MySQL-backed database.
17
+ * @param input MySQL pool configuration, pool, connection, or URI.
18
+ * @param options Database runtime and recreation options.
19
+ */
20
+ constructor(input: MysqlDatabaseInput, options: MysqlDatabaseOptions = {}) {
21
+ super(new MysqlDatabaseDriver(input, options), options)
22
+ }
23
+ }
24
+
25
+ /**
26
+ * Creates a MySQL-backed database.
27
+ *
28
+ * @param input MySQL pool configuration, pool, connection, or URI.
29
+ * @param options Database runtime and recreation options.
30
+ * @returns A MySQL database.
31
+ * @example
32
+ * ```ts
33
+ * import { createMysqlDatabase } from 'remix/data-table/mysql'
34
+ *
35
+ * let db = createMysqlDatabase({
36
+ * uri: process.env.DATABASE_URL,
37
+ * multipleStatements: true,
38
+ * })
39
+ * ```
40
+ */
41
+ export function createMysqlDatabase(
42
+ input: MysqlDatabaseInput,
43
+ options: MysqlDatabaseOptions = {},
44
+ ): MysqlDatabase {
45
+ return new MysqlDatabase(input, options)
46
+ }