@nextlyhq/adapter-drizzle 0.0.2-alpha.37 → 0.0.2-alpha.39
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/dist/{adapter-C4aTSnjr.d.cts → adapter-BXgnu6Ao.d.cts} +1 -48
- package/dist/{adapter-Du9mkzJT.d.ts → adapter-CWTncnCq.d.ts} +1 -48
- package/dist/index.cjs +16 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.mjs +16 -1
- package/dist/index.mjs.map +1 -1
- package/dist/{migration-BVH4_wPB.d.ts → migration-CzQxJoz1.d.ts} +17 -0
- package/dist/{migration-UX4eZjAX.d.cts → migration-YLYiVdVc.d.cts} +17 -0
- package/dist/migrations.d.cts +3 -3
- package/dist/migrations.d.ts +3 -3
- package/dist/types/index.d.cts +1 -1
- package/dist/types/index.d.ts +1 -1
- package/package.json +3 -3
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AnyRelations } from 'drizzle-orm';
|
|
2
2
|
import { S as SupportedDialect, a as SqlParam, T as TableResolver } from './core-CVO7WYDj.cjs';
|
|
3
|
-
import { T as TransactionContext, e as TransactionOptions, D as DatabaseCapabilities, P as PoolStats, S as SelectOptions, I as InsertOptions, W as WhereClause, U as UpdateOptions, f as DeleteOptions, g as UpsertOptions, a as Migration, d as MigrationResult } from './migration-
|
|
3
|
+
import { T as TransactionContext, e as TransactionOptions, D as DatabaseCapabilities, P as PoolStats, S as SelectOptions, I as InsertOptions, W as WhereClause, U as UpdateOptions, f as DeleteOptions, g as UpsertOptions, a as Migration, d as MigrationResult } from './migration-YLYiVdVc.cjs';
|
|
4
4
|
import { T as TableDefinition, C as CreateTableOptions, D as DropTableOptions, A as AlterTableOperation, a as AlterTableOptions } from './schema-BDn8WfSL.cjs';
|
|
5
5
|
import { D as DatabaseErrorKind, a as DatabaseError } from './error-um1d_3Uo.cjs';
|
|
6
6
|
|
|
@@ -17,53 +17,6 @@ import { D as DatabaseErrorKind, a as DatabaseError } from './error-um1d_3Uo.cjs
|
|
|
17
17
|
* @packageDocumentation
|
|
18
18
|
*/
|
|
19
19
|
|
|
20
|
-
/**
|
|
21
|
-
* Abstract base class for database adapters.
|
|
22
|
-
*
|
|
23
|
-
* @remarks
|
|
24
|
-
* All dialect-specific adapters must extend this class and implement the abstract methods.
|
|
25
|
-
* Default implementations are provided for CRUD operations, which can be overridden for
|
|
26
|
-
* optimization or dialect-specific behavior.
|
|
27
|
-
*
|
|
28
|
-
* ## Required Implementations
|
|
29
|
-
*
|
|
30
|
-
* Subclasses must implement:
|
|
31
|
-
* - `dialect` - Database dialect identifier
|
|
32
|
-
* - `connect()` - Establish database connection
|
|
33
|
-
* - `disconnect()` - Close database connection
|
|
34
|
-
* - `executeQuery()` - Execute raw SQL query
|
|
35
|
-
* - `transaction()` - Execute operations within a transaction
|
|
36
|
-
* - `getCapabilities()` - Report database feature support
|
|
37
|
-
*
|
|
38
|
-
* ## Optional Overrides
|
|
39
|
-
*
|
|
40
|
-
* Subclasses can override default CRUD methods for optimization:
|
|
41
|
-
* - `select()`, `selectOne()` - Custom query optimization
|
|
42
|
-
* - `insert()`, `insertMany()` - Bulk insert optimization
|
|
43
|
-
* - `update()`, `delete()` - Custom update/delete logic
|
|
44
|
-
* - `upsert()` - Dialect-specific upsert syntax
|
|
45
|
-
*
|
|
46
|
-
* @example
|
|
47
|
-
* ```typescript
|
|
48
|
-
* export class PostgresAdapter extends DrizzleAdapter {
|
|
49
|
-
* readonly dialect = 'postgresql' as const;
|
|
50
|
-
*
|
|
51
|
-
* async connect() {
|
|
52
|
-
* this.pool = new Pool({ connectionString: this.config.url });
|
|
53
|
-
* // ... connection logic
|
|
54
|
-
* }
|
|
55
|
-
*
|
|
56
|
-
* async executeQuery<T>(sql: string, params?: SqlParam[]) {
|
|
57
|
-
* const result = await this.pool.query(sql, params);
|
|
58
|
-
* return result.rows as T[];
|
|
59
|
-
* }
|
|
60
|
-
*
|
|
61
|
-
* // ... other required methods
|
|
62
|
-
* }
|
|
63
|
-
* ```
|
|
64
|
-
*
|
|
65
|
-
* @public
|
|
66
|
-
*/
|
|
67
20
|
declare abstract class DrizzleAdapter {
|
|
68
21
|
/**
|
|
69
22
|
* Database dialect identifier.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AnyRelations } from 'drizzle-orm';
|
|
2
2
|
import { S as SupportedDialect, a as SqlParam, T as TableResolver } from './core-CVO7WYDj.js';
|
|
3
|
-
import { T as TransactionContext, e as TransactionOptions, D as DatabaseCapabilities, P as PoolStats, S as SelectOptions, I as InsertOptions, W as WhereClause, U as UpdateOptions, f as DeleteOptions, g as UpsertOptions, a as Migration, d as MigrationResult } from './migration-
|
|
3
|
+
import { T as TransactionContext, e as TransactionOptions, D as DatabaseCapabilities, P as PoolStats, S as SelectOptions, I as InsertOptions, W as WhereClause, U as UpdateOptions, f as DeleteOptions, g as UpsertOptions, a as Migration, d as MigrationResult } from './migration-CzQxJoz1.js';
|
|
4
4
|
import { T as TableDefinition, C as CreateTableOptions, D as DropTableOptions, A as AlterTableOperation, a as AlterTableOptions } from './schema-BIQ0YQZ_.js';
|
|
5
5
|
import { D as DatabaseErrorKind, a as DatabaseError } from './error-um1d_3Uo.js';
|
|
6
6
|
|
|
@@ -17,53 +17,6 @@ import { D as DatabaseErrorKind, a as DatabaseError } from './error-um1d_3Uo.js'
|
|
|
17
17
|
* @packageDocumentation
|
|
18
18
|
*/
|
|
19
19
|
|
|
20
|
-
/**
|
|
21
|
-
* Abstract base class for database adapters.
|
|
22
|
-
*
|
|
23
|
-
* @remarks
|
|
24
|
-
* All dialect-specific adapters must extend this class and implement the abstract methods.
|
|
25
|
-
* Default implementations are provided for CRUD operations, which can be overridden for
|
|
26
|
-
* optimization or dialect-specific behavior.
|
|
27
|
-
*
|
|
28
|
-
* ## Required Implementations
|
|
29
|
-
*
|
|
30
|
-
* Subclasses must implement:
|
|
31
|
-
* - `dialect` - Database dialect identifier
|
|
32
|
-
* - `connect()` - Establish database connection
|
|
33
|
-
* - `disconnect()` - Close database connection
|
|
34
|
-
* - `executeQuery()` - Execute raw SQL query
|
|
35
|
-
* - `transaction()` - Execute operations within a transaction
|
|
36
|
-
* - `getCapabilities()` - Report database feature support
|
|
37
|
-
*
|
|
38
|
-
* ## Optional Overrides
|
|
39
|
-
*
|
|
40
|
-
* Subclasses can override default CRUD methods for optimization:
|
|
41
|
-
* - `select()`, `selectOne()` - Custom query optimization
|
|
42
|
-
* - `insert()`, `insertMany()` - Bulk insert optimization
|
|
43
|
-
* - `update()`, `delete()` - Custom update/delete logic
|
|
44
|
-
* - `upsert()` - Dialect-specific upsert syntax
|
|
45
|
-
*
|
|
46
|
-
* @example
|
|
47
|
-
* ```typescript
|
|
48
|
-
* export class PostgresAdapter extends DrizzleAdapter {
|
|
49
|
-
* readonly dialect = 'postgresql' as const;
|
|
50
|
-
*
|
|
51
|
-
* async connect() {
|
|
52
|
-
* this.pool = new Pool({ connectionString: this.config.url });
|
|
53
|
-
* // ... connection logic
|
|
54
|
-
* }
|
|
55
|
-
*
|
|
56
|
-
* async executeQuery<T>(sql: string, params?: SqlParam[]) {
|
|
57
|
-
* const result = await this.pool.query(sql, params);
|
|
58
|
-
* return result.rows as T[];
|
|
59
|
-
* }
|
|
60
|
-
*
|
|
61
|
-
* // ... other required methods
|
|
62
|
-
* }
|
|
63
|
-
* ```
|
|
64
|
-
*
|
|
65
|
-
* @public
|
|
66
|
-
*/
|
|
67
20
|
declare abstract class DrizzleAdapter {
|
|
68
21
|
/**
|
|
69
22
|
* Database dialect identifier.
|
package/dist/index.cjs
CHANGED
|
@@ -108,6 +108,21 @@ function createDatabaseError(options) {
|
|
|
108
108
|
}
|
|
109
109
|
|
|
110
110
|
// src/adapter.ts
|
|
111
|
+
function affectedRowCount(result) {
|
|
112
|
+
if (Array.isArray(result)) {
|
|
113
|
+
const header = result[0];
|
|
114
|
+
if (header && typeof header.affectedRows === "number") {
|
|
115
|
+
return header.affectedRows;
|
|
116
|
+
}
|
|
117
|
+
return result.length;
|
|
118
|
+
}
|
|
119
|
+
const record = result;
|
|
120
|
+
const rowCount = record?.rowCount;
|
|
121
|
+
if (typeof rowCount === "number") return rowCount;
|
|
122
|
+
const changes = record?.changes;
|
|
123
|
+
if (typeof changes === "number") return changes;
|
|
124
|
+
return 0;
|
|
125
|
+
}
|
|
111
126
|
var DrizzleAdapter = class {
|
|
112
127
|
// ============================================================
|
|
113
128
|
// Drizzle Query API Support
|
|
@@ -678,7 +693,7 @@ var DrizzleAdapter = class {
|
|
|
678
693
|
query = query.where(whereCondition);
|
|
679
694
|
}
|
|
680
695
|
const result = await query;
|
|
681
|
-
return
|
|
696
|
+
return affectedRowCount(result);
|
|
682
697
|
} catch (error) {
|
|
683
698
|
throw this.handleQueryError(error, "delete", table);
|
|
684
699
|
}
|