flashorm 2.0.8 → 2.1.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 CHANGED
@@ -17,14 +17,14 @@ A powerful, database-agnostic migration CLI tool built in Go with multi-database
17
17
 
18
18
  ## 📊 Performance
19
19
 
20
- | Operation | FlashORM | Drizzle | Prisma |
21
- |-----------|-------|---------|--------|
22
- | Insert 1000 Users | **158ms** | 224ms | 230ms |
23
- | Insert 10 Cat + 5K Posts + 15K Comments | **2410ms** | 3028ms | 3977ms |
24
- | Complex Query x500 | **4071ms** | 12500ms | 56322ms |
25
- | Mixed Workload x1000 (75% read, 25% write) | **186ms** | 1174ms | 10863ms |
26
- | Stress Test Simple Query x2000 | **122ms** | 160ms | 223ms |
27
- | **TOTAL** | **6947ms** | **17149ms** | **71551ms** |
20
+ | Operation | FlashORM | Drizzle | Prisma |
21
+ | ------------------------------------------ | ---------- | ----------- | ----------- |
22
+ | Insert 1000 Users | **149ms** | 224ms | 230ms |
23
+ | Insert 10 Cat + 5K Posts + 15K Comments | **2410ms** | 3028ms | 3977ms |
24
+ | Complex Query x500 | **3156ms** | 12500ms | 56322ms |
25
+ | Mixed Workload x1000 (75% read, 25% write) | **186ms** | 1174ms | 10863ms |
26
+ | Stress Test Simple Query x2000 | **79ms** | 160ms | 118ms |
27
+ | **TOTAL** | **5980ms** | **17149ms** | **71510ms** |
28
28
 
29
29
  ## 🚀 Installation
30
30
 
@@ -41,6 +41,7 @@ bun pm trust flashorm
41
41
  ```
42
42
 
43
43
  Or add to your `package.json`:
44
+
44
45
  ```json
45
46
  {
46
47
  "trustedDependencies": ["flashorm"]
@@ -56,6 +57,7 @@ flash init --postgresql # or --mysql, --sqlite
56
57
  ```
57
58
 
58
59
  This creates:
60
+
59
61
  ```
60
62
  your-project/
61
63
  ├── flash.config.json
@@ -77,6 +79,7 @@ DATABASE_URL=postgresql://user:password@localhost:5432/mydb
77
79
  ### 3. Define Schema
78
80
 
79
81
  **db/schema/schema.sql**
82
+
80
83
  ```sql
81
84
  CREATE TABLE users (
82
85
  id SERIAL PRIMARY KEY,
@@ -90,6 +93,7 @@ CREATE TABLE users (
90
93
  ### 4. Write Queries
91
94
 
92
95
  **db/queries/users.sql**
96
+
93
97
  ```sql
94
98
  -- name: GetUser :one
95
99
  SELECT id, name, email, created_at, updated_at FROM users
@@ -133,6 +137,7 @@ flash gen
133
137
  ```
134
138
 
135
139
  **Generated Types (flash_gen/index.d.ts)**
140
+
136
141
  ```typescript
137
142
  // Code generated by FlashORM. DO NOT EDIT.
138
143
 
@@ -168,41 +173,48 @@ export function New(db: any): Queries;
168
173
  ### 8. Use in Your Code
169
174
 
170
175
  **index.ts**
176
+
171
177
  ```typescript
172
- import { Pool } from 'pg';
173
- import { New } from './flash_gen/database';
178
+ import { Pool } from "pg";
179
+ import { New } from "./flash_gen/database";
174
180
 
175
- const DATABASE_URL = process.env.DATABASE_URL || 'postgresql://postgres:postgres@localhost:5432/mydb';
181
+ const DATABASE_URL =
182
+ process.env.DATABASE_URL ||
183
+ "postgresql://postgres:postgres@localhost:5432/mydb";
176
184
 
177
185
  async function main() {
178
- const pool = new Pool({
179
- connectionString: DATABASE_URL,
180
- });
181
-
182
- const db = New(pool);
183
-
184
- // Create user - fully type-safe!
185
- const newUser = await db.createUser('Alice', 'alice@example.com');
186
- console.log('New user:', newUser);
187
-
188
- // Get user by ID
189
- const user = await db.getUser(newUser.id);
190
- console.log('Found user:', user);
191
-
192
- // List all users
193
- const users = await db.listUsers();
194
- console.log('All users:', users);
195
-
196
- // Update user
197
- const updated = await db.updateUser(newUser.id, 'Alice Smith', 'alice.smith@example.com');
198
- console.log('Updated user:', updated);
199
-
200
- await pool.end();
186
+ const pool = new Pool({
187
+ connectionString: DATABASE_URL,
188
+ });
189
+
190
+ const db = New(pool);
191
+
192
+ // Create user - fully type-safe!
193
+ const newUser = await db.createUser("Alice", "alice@example.com");
194
+ console.log("New user:", newUser);
195
+
196
+ // Get user by ID
197
+ const user = await db.getUser(newUser.id);
198
+ console.log("Found user:", user);
199
+
200
+ // List all users
201
+ const users = await db.listUsers();
202
+ console.log("All users:", users);
203
+
204
+ // Update user
205
+ const updated = await db.updateUser(
206
+ newUser.id,
207
+ "Alice Smith",
208
+ "alice.smith@example.com"
209
+ );
210
+ console.log("Updated user:", updated);
211
+
212
+ await pool.end();
201
213
  }
202
214
 
203
215
  main().catch((err) => {
204
- console.error('Error:', err);
205
- process.exit(1);
216
+ console.error("Error:", err);
217
+ process.exit(1);
206
218
  });
207
219
  ```
208
220
 
@@ -225,6 +237,7 @@ flash studio --browser=false
225
237
  ```
226
238
 
227
239
  **Studio Features:**
240
+
228
241
  - 📊 **Data Browser**: View and edit table data with inline editing
229
242
  - 💻 **SQL Editor**: Execute queries with CodeMirror syntax highlighting
230
243
  - 🎨 **Schema Visualization**: Interactive database diagram with React + ReactFlow
@@ -333,6 +346,7 @@ flash <command> --help
333
346
  ## ⚙️ Configuration
334
347
 
335
348
  **flash.config.json**
349
+
336
350
  ```json
337
351
  {
338
352
  "version": "2",
@@ -346,7 +360,7 @@ flash <command> --help
346
360
  },
347
361
  "gen": {
348
362
  "js": {
349
- "enabled": true,
363
+ "enabled": true
350
364
  }
351
365
  }
352
366
  }
@@ -355,6 +369,7 @@ flash <command> --help
355
369
  ## 🎨 PostgreSQL ENUM Support
356
370
 
357
371
  **Schema with ENUMs**
372
+
358
373
  ```sql
359
374
  CREATE TYPE user_role AS ENUM ('admin', 'user', 'guest');
360
375
 
@@ -366,6 +381,7 @@ CREATE TABLE users (
366
381
  ```
367
382
 
368
383
  **Query with ENUM**
384
+
369
385
  ```sql
370
386
  -- name: GetUsersByRole :many
371
387
  SELECT id, name, role FROM users
@@ -373,8 +389,9 @@ WHERE role = $1;
373
389
  ```
374
390
 
375
391
  **Generated TypeScript**
392
+
376
393
  ```typescript
377
- export type UserRole = 'admin' | 'user' | 'guest';
394
+ export type UserRole = "admin" | "user" | "guest";
378
395
 
379
396
  export interface Users {
380
397
  id: number | null;
@@ -398,6 +415,7 @@ $ flash apply
398
415
  ```
399
416
 
400
417
  If a migration fails:
418
+
401
419
  ```bash
402
420
  ❌ Failed at migration: 20251103_bad_migration
403
421
  Error: syntax error at or near "INVALID"
@@ -423,31 +441,35 @@ Create export before applying? (y/n): y
423
441
  ## 📤 Export Formats
424
442
 
425
443
  ### JSON Export
444
+
426
445
  ```bash
427
446
  flash export --json
428
447
  ```
448
+
429
449
  ```json
430
450
  {
431
451
  "timestamp": "2025-11-03 16:30:00",
432
452
  "version": "1.0",
433
453
  "tables": {
434
- "users": [
435
- {"id": 1, "name": "Alice", "email": "alice@example.com"}
436
- ]
454
+ "users": [{ "id": 1, "name": "Alice", "email": "alice@example.com" }]
437
455
  }
438
456
  }
439
457
  ```
440
458
 
441
459
  ### CSV Export
460
+
442
461
  ```bash
443
462
  flash export --csv
444
463
  ```
464
+
445
465
  Creates directory with individual CSV files per table.
446
466
 
447
467
  ### SQLite Export
468
+
448
469
  ```bash
449
470
  flash export --sqlite
450
471
  ```
472
+
451
473
  Creates portable `.db` file.
452
474
 
453
475
  ## 🎨 FlashORM Studio
@@ -463,6 +485,7 @@ Open http://localhost:5555 (or your custom port)
463
485
  **Features:**
464
486
 
465
487
  ### 1. Data Browser (`/`)
488
+
466
489
  - View all tables in sidebar
467
490
  - Click any table to view/edit data
468
491
  - Double-click cells for inline editing
@@ -472,6 +495,7 @@ Open http://localhost:5555 (or your custom port)
472
495
  - Foreign key hints
473
496
 
474
497
  ### 2. SQL Editor (`/sql`)
498
+
475
499
  - Execute custom SQL queries
476
500
  - CodeMirror editor with syntax highlighting
477
501
  - Press Ctrl+Enter to run queries
@@ -480,6 +504,7 @@ Open http://localhost:5555 (or your custom port)
480
504
  - Query history
481
505
 
482
506
  ### 3. Schema Visualization (`/schema`)
507
+
483
508
  - Interactive database diagram
484
509
  - React + ReactFlow rendering
485
510
  - Automatic layout with Dagre algorithm
@@ -489,6 +514,7 @@ Open http://localhost:5555 (or your custom port)
489
514
  - MiniMap for navigation
490
515
 
491
516
  **Tech Stack:**
517
+
492
518
  - Backend: Go Fiber v2.52.9
493
519
  - Frontend: React 18.2.0, ReactFlow 12.8.4, CodeMirror 5.65.2
494
520
  - All assets embedded in single binary
@@ -509,6 +535,7 @@ flash raw "SELECT COUNT(*) FROM orders"
509
535
  ```
510
536
 
511
537
  **Features:**
538
+
512
539
  - ✅ Beautiful table output for SELECT queries
513
540
  - ✅ Multi-statement execution
514
541
  - ✅ Transaction support
@@ -516,6 +543,7 @@ flash raw "SELECT COUNT(*) FROM orders"
516
543
  - ✅ Formatted error messages
517
544
 
518
545
  **Example Output:**
546
+
519
547
  ```bash
520
548
  $ flash raw -q "SELECT id, name, email FROM users LIMIT 3"
521
549
 
@@ -537,13 +565,13 @@ $ flash raw -q "SELECT id, name, email FROM users LIMIT 3"
537
565
  ## 🔧 Programmatic API
538
566
 
539
567
  ```javascript
540
- const flash = require('flashorm');
568
+ const flash = require("flashorm");
541
569
 
542
570
  // Execute commands
543
- flash.exec('status');
571
+ flash.exec("status");
544
572
  flash.exec('migrate "add users"');
545
- flash.exec('apply');
546
- flash.exec('studio'); // Launch Studio
573
+ flash.exec("apply");
574
+ flash.exec("studio"); // Launch Studio
547
575
 
548
576
  // Get binary path
549
577
  const binaryPath = flash.getBinaryPath();
@@ -552,6 +580,7 @@ const binaryPath = flash.getBinaryPath();
552
580
  ## 📚 Examples
553
581
 
554
582
  Check out complete examples:
583
+
555
584
  - [TypeScript Example](https://github.com/Lumos-Labs-HQ/flash/tree/main/example/ts)
556
585
  - [Go Example](https://github.com/Lumos-Labs-HQ/flash/tree/main/example/go)
557
586
 
@@ -576,6 +605,7 @@ Check your `DATABASE_URL` in `.env` file.
576
605
  ### Studio Not Loading
577
606
 
578
607
  Make sure port 5555 is not in use, or specify a different port:
608
+
579
609
  ```bash
580
610
  flash studio --port 3000
581
611
  ```
@@ -600,4 +630,4 @@ flash studio --port 3000
600
630
 
601
631
  MIT License - see [LICENSE](https://github.com/Lumos-Labs-HQ/flash/blob/main/LICENSE)
602
632
 
603
- ---
633
+ ---
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "flashorm",
3
- "version": "2.0.8",
3
+ "version": "2.1.0",
4
4
  "description": "A powerful, database-agnostic migration CLI tool with multi-database support and type-safe code generation",
5
5
  "main": "index.js",
6
6
  "bin": {
@@ -4,7 +4,7 @@ const https = require('https');
4
4
  const fs = require('fs');
5
5
  const path = require('path');
6
6
 
7
- const VERSION = '2.0.8';
7
+ const VERSION = '2.1.0';
8
8
  const REPO = 'Lumos-Labs-HQ/flash';
9
9
 
10
10
  const platform = process.platform;