driftsql 1.0.23 → 1.0.24

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.
Files changed (2) hide show
  1. package/README.md +62 -2
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -3,7 +3,7 @@
3
3
  [![npm version](https://img.shields.io/npm/v/driftsql?color=yellow)](https://npmjs.com/package/driftsql)
4
4
  [![npm downloads](https://img.shields.io/npm/dm/driftsql?color=yellow)](https://npm.chart.dev/driftsql)
5
5
 
6
- A lightweight, type-safe SQL client for TypeScript with support for PostgreSQL, MySQL, and LibSQL/SQLite.
6
+ A lightweight, type-safe SQL client for TypeScript with support for PostgreSQL, MySQL, LibSQL/SQLite, and Neon.
7
7
 
8
8
  ## Installation
9
9
 
@@ -41,11 +41,14 @@ const newUser = await client.insert('users', { name: 'John', email: 'john@exampl
41
41
  ## Supported Databases
42
42
 
43
43
  ```typescript
44
- import { PostgresDriver, LibSQLDriver, MySQLDriver, SQLClient } from 'driftsql'
44
+ import { PostgresDriver, LibSQLDriver, MySQLDriver, NeonDriver, SQLClient } from 'driftsql'
45
45
 
46
46
  // PostgreSQL
47
47
  const pg = new PostgresDriver({ connectionString: 'postgresql://...' })
48
48
 
49
+ // Neon
50
+ const neon = new NeonDriver({ connectionString: 'postgresql://...' })
51
+
49
52
  // LibSQL/Turso/SQLite
50
53
  const libsql = new LibSQLDriver({ url: 'libsql://...', authToken: '...' })
51
54
  // or for local SQLite: new LibSQLDriver({ url: 'file:./database.db' })
@@ -83,6 +86,63 @@ class MyCustomDriver implements DatabaseDriver {
83
86
  const client = new SQLClient({ driver: new MyCustomDriver() })
84
87
  ```
85
88
 
89
+ ## Database Inspection
90
+
91
+ Generate TypeScript interfaces from your database schema:
92
+
93
+ ```typescript
94
+ import { inspectDB, PostgresDriver } from 'driftsql'
95
+
96
+ const driver = new PostgresDriver({
97
+ connectionString: 'postgresql://user:password@localhost:5432/mydb',
98
+ })
99
+
100
+ // Generate types for all tables
101
+ await inspectDB({
102
+ driver,
103
+ outputFile: 'db-types.ts', // optional, defaults to 'db-types.ts'
104
+ })
105
+ ```
106
+
107
+ This will create a file with TypeScript interfaces for each table:
108
+
109
+ ```typescript
110
+ // Generated db-types.ts
111
+ export interface Users {
112
+ id: number
113
+ name: string
114
+ email: string
115
+ created_at: Date
116
+ active: boolean | null
117
+ }
118
+
119
+ export interface Posts {
120
+ id: number
121
+ title: string
122
+ content: string
123
+ user_id: number
124
+ published: boolean
125
+ }
126
+
127
+ export interface Database {
128
+ users: Users
129
+ posts: Posts
130
+ }
131
+ ```
132
+
133
+ Then use the generated types with your client:
134
+
135
+ ```typescript
136
+ import type { Database } from './db-types'
137
+ import { PostgresDriver, SQLClient } from 'driftsql'
138
+
139
+ const client = new SQLClient<Database>({ driver })
140
+
141
+ // Now you get full type safety
142
+ const user = await client.findFirst('users', { email: 'test@example.com' }) // Returns Users | null
143
+ const posts = await client.findMany('posts', { where: { published: true } }) // Returns Posts[]
144
+ ```
145
+
86
146
  ## License
87
147
 
88
148
  Published under the [MIT](https://github.com/lassejlv/driftsql/blob/main/LICENSE) license.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "driftsql",
3
- "version": "1.0.23",
3
+ "version": "1.0.24",
4
4
  "main": "dist/index.js",
5
5
  "description": "A lightweight SQL client for TypeScript",
6
6
  "scripts": {