litedbmodel 0.22.3 → 1.0.1
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 +90 -80
- package/dist/Column.d.ts +17 -9
- package/dist/Column.d.ts.map +1 -1
- package/dist/Column.js +39 -4
- package/dist/Column.js.map +1 -1
- package/dist/DBModel.d.ts +44 -18
- package/dist/DBModel.d.ts.map +1 -1
- package/dist/DBModel.js +124 -63
- package/dist/DBModel.js.map +1 -1
- package/dist/LazyRelation.d.ts.map +1 -1
- package/dist/LazyRelation.js +9 -3
- package/dist/LazyRelation.js.map +1 -1
- package/dist/SqlFragment.d.ts +118 -0
- package/dist/SqlFragment.d.ts.map +1 -0
- package/dist/SqlFragment.js +237 -0
- package/dist/SqlFragment.js.map +1 -0
- package/dist/decorators.d.ts.map +1 -1
- package/dist/decorators.js +6 -8
- package/dist/decorators.js.map +1 -1
- package/dist/drivers/PostgresHelper.d.ts.map +1 -1
- package/dist/drivers/PostgresHelper.js +4 -0
- package/dist/drivers/PostgresHelper.js.map +1 -1
- package/dist/drivers/postgres.d.ts.map +1 -1
- package/dist/drivers/postgres.js +57 -10
- package/dist/drivers/postgres.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +14 -1
- package/dist/index.js.map +1 -1
- package/docs/BENCHMARK.md +52 -52
- package/docs/COMPARISON.md +30 -25
- package/docs/benchmark-chart.svg +163 -163
- package/docs/sql-tagged-template.md +259 -0
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -11,6 +11,7 @@ type DBConfig, type DBConnection, } from './DBHandler';
|
|
|
11
11
|
export { DBConditions, DBOrConditions, and, or as _legacyOr, normalizeConditions, type ConditionObject, type ConditionValue } from './DBConditions';
|
|
12
12
|
export { DBToken, DBImmediateValue, DBNullValue, DBNotNullValue, DBBoolValue, DBArrayValue, DBDynamicValue, DBRawValue, DBTupleIn, DBCast, DBCastArray, DBSubquery, DBExists, DBParentRef, type SubqueryCondition, dbNull, dbNotNull, dbTrue, dbFalse, dbNow, dbIn, dbDynamic, dbRaw, dbImmediate, dbTupleIn, parentRef, dbCast, dbUuid, dbCastIn, dbUuidIn, } from './DBValues';
|
|
13
13
|
export { type Column, createColumn, isColumn, type ColumnsOf, type ColumnOf, type ModelOfColumn, Values, Conditions, OrderColumn, isOrderColumn, type OrderColumnOf, type OrderSpec, orderToString, columnsToNames, type CV, type CVs, pairsToRecord, SKIP, type SkipType, type Cond, type CondOf, type CondElement, type CondElementOf, type Conds, type CondsOf, type OrCond, type OrCondOf, isOrCond, condsToRecord, } from './Column';
|
|
14
|
+
export { sql, type SqlFragment, type SqlTypedFragment, type SqlCondition, type SqlInterpolation, SqlRaw, SqlRef, isSqlFragment, isSqlTypedFragment, isSqlCondition, isAnySqlFragment, isSqlRaw, isSqlRef, } from './SqlFragment';
|
|
14
15
|
export { model, column, hasMany, belongsTo, hasOne, getColumnMeta, getRelationMeta, getModelColumnNames, getModelPropertyNames, type ColumnOptions, type ColumnMeta, type RelationMeta, type RelationType, type KeyPair, type CompositeKeyPairs, type KeysFactory, type RelationDecoratorOptions, } from './decorators';
|
|
15
16
|
export { castToDatetime, castToBoolean, castToIntegerArray, castToNumericArray, castToStringArray, castToBooleanArray, castToDatetimeArray, castToJson, getTypeCast, setTypeCastImpl, resetTypeCastImpl, type TypeCastFunctions, } from './TypeCast';
|
|
16
17
|
export { LazyRelationContext, createRelationContext, preloadRelations, type RelationConfig, } from './LazyRelation';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAMH,OAAO,EACL,OAAO,EACP,qBAAqB,EACrB,wBAAwB,EACxB,oBAAoB,GACrB,MAAM,WAAW,CAAC;AACnB,OAAO,EACL,SAAS,EACT,aAAa,EACb,aAAa,EACb,YAAY,EACZ,WAAW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EAAE,MAAM,eAAe,CAAC;AAMrD,YAAY,EACV,aAAa,EACb,aAAa,EACb,aAAa,EACb,aAAa,EACb,iBAAiB,EACjB,kBAAkB,EAClB,MAAM,EACN,WAAW,EACX,YAAY,EACZ,eAAe,EACf,UAAU,GACX,MAAM,SAAS,CAAC;AACjB,OAAO,EACL,kBAAkB,EAClB,4BAA4B,EAC5B,2BAA2B,GAC5B,MAAM,SAAS,CAAC;AAMjB,OAAO,EACL,cAAc,EACd,oBAAoB,EACpB,YAAY,EACZ,kBAAkB,EAClB,KAAK,QAAQ,EACb,KAAK,eAAe,EACpB,KAAK,WAAW,GACjB,MAAM,WAAW,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
*/
|
|
9
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
10
|
exports.OrderColumn = exports.Conditions = exports.Values = exports.isColumn = exports.createColumn = exports.dbUuidIn = exports.dbCastIn = exports.dbUuid = exports.dbCast = exports.parentRef = exports.dbTupleIn = exports.dbImmediate = exports.dbRaw = exports.dbDynamic = exports.dbIn = exports.dbNow = exports.dbFalse = exports.dbTrue = exports.dbNotNull = exports.dbNull = exports.DBParentRef = exports.DBExists = exports.DBSubquery = exports.DBCastArray = exports.DBCast = exports.DBTupleIn = exports.DBRawValue = exports.DBDynamicValue = exports.DBArrayValue = exports.DBBoolValue = exports.DBNotNullValue = exports.DBNullValue = exports.DBImmediateValue = exports.DBToken = exports.normalizeConditions = exports._legacyOr = exports.and = exports.DBOrConditions = exports.DBConditions = exports.createHandlerWithClient = exports.createHandlerWithConnection = exports.getDBConfig = exports.getDBHandler = exports.initDBHandler = exports.closeAllPools = exports.DBHandler = exports.getTransactionClient = exports.getTransactionConnection = exports.getTransactionContext = exports.DBModel = void 0;
|
|
11
|
-
exports.createSqliteDriver = exports.SqliteDriver = exports.createPostgresDriver = exports.PostgresDriver = exports.WriteInReadOnlyContextError = exports.WriteOutsideTransactionError = exports.LimitExceededError = exports.StatisticsMiddleware = exports.createMiddleware = exports.Middleware = exports.LazyLoadingDBModel = exports.preloadRelations = exports.createRelationContext = exports.LazyRelationContext = exports.resetTypeCastImpl = exports.setTypeCastImpl = exports.getTypeCast = exports.castToJson = exports.castToDatetimeArray = exports.castToBooleanArray = exports.castToStringArray = exports.castToNumericArray = exports.castToIntegerArray = exports.castToBoolean = exports.castToDatetime = exports.getModelPropertyNames = exports.getModelColumnNames = exports.getRelationMeta = exports.getColumnMeta = exports.hasOne = exports.belongsTo = exports.hasMany = exports.column = exports.model = exports.condsToRecord = exports.isOrCond = exports.SKIP = exports.pairsToRecord = exports.columnsToNames = exports.orderToString = exports.isOrderColumn = void 0;
|
|
11
|
+
exports.createSqliteDriver = exports.SqliteDriver = exports.createPostgresDriver = exports.PostgresDriver = exports.WriteInReadOnlyContextError = exports.WriteOutsideTransactionError = exports.LimitExceededError = exports.StatisticsMiddleware = exports.createMiddleware = exports.Middleware = exports.LazyLoadingDBModel = exports.preloadRelations = exports.createRelationContext = exports.LazyRelationContext = exports.resetTypeCastImpl = exports.setTypeCastImpl = exports.getTypeCast = exports.castToJson = exports.castToDatetimeArray = exports.castToBooleanArray = exports.castToStringArray = exports.castToNumericArray = exports.castToIntegerArray = exports.castToBoolean = exports.castToDatetime = exports.getModelPropertyNames = exports.getModelColumnNames = exports.getRelationMeta = exports.getColumnMeta = exports.hasOne = exports.belongsTo = exports.hasMany = exports.column = exports.model = exports.isSqlRef = exports.isSqlRaw = exports.isAnySqlFragment = exports.isSqlCondition = exports.isSqlTypedFragment = exports.isSqlFragment = exports.SqlRef = exports.SqlRaw = exports.sql = exports.condsToRecord = exports.isOrCond = exports.SKIP = exports.pairsToRecord = exports.columnsToNames = exports.orderToString = exports.isOrderColumn = void 0;
|
|
12
12
|
// ============================================
|
|
13
13
|
// Core Classes
|
|
14
14
|
// ============================================
|
|
@@ -85,6 +85,19 @@ Object.defineProperty(exports, "pairsToRecord", { enumerable: true, get: functio
|
|
|
85
85
|
Object.defineProperty(exports, "SKIP", { enumerable: true, get: function () { return Column_1.SKIP; } });
|
|
86
86
|
Object.defineProperty(exports, "isOrCond", { enumerable: true, get: function () { return Column_1.isOrCond; } });
|
|
87
87
|
Object.defineProperty(exports, "condsToRecord", { enumerable: true, get: function () { return Column_1.condsToRecord; } });
|
|
88
|
+
// ============================================
|
|
89
|
+
// SQL Tagged Template Literal
|
|
90
|
+
// ============================================
|
|
91
|
+
var SqlFragment_1 = require("./SqlFragment");
|
|
92
|
+
Object.defineProperty(exports, "sql", { enumerable: true, get: function () { return SqlFragment_1.sql; } });
|
|
93
|
+
Object.defineProperty(exports, "SqlRaw", { enumerable: true, get: function () { return SqlFragment_1.SqlRaw; } });
|
|
94
|
+
Object.defineProperty(exports, "SqlRef", { enumerable: true, get: function () { return SqlFragment_1.SqlRef; } });
|
|
95
|
+
Object.defineProperty(exports, "isSqlFragment", { enumerable: true, get: function () { return SqlFragment_1.isSqlFragment; } });
|
|
96
|
+
Object.defineProperty(exports, "isSqlTypedFragment", { enumerable: true, get: function () { return SqlFragment_1.isSqlTypedFragment; } });
|
|
97
|
+
Object.defineProperty(exports, "isSqlCondition", { enumerable: true, get: function () { return SqlFragment_1.isSqlCondition; } });
|
|
98
|
+
Object.defineProperty(exports, "isAnySqlFragment", { enumerable: true, get: function () { return SqlFragment_1.isAnySqlFragment; } });
|
|
99
|
+
Object.defineProperty(exports, "isSqlRaw", { enumerable: true, get: function () { return SqlFragment_1.isSqlRaw; } });
|
|
100
|
+
Object.defineProperty(exports, "isSqlRef", { enumerable: true, get: function () { return SqlFragment_1.isSqlRef; } });
|
|
88
101
|
var decorators_1 = require("./decorators");
|
|
89
102
|
Object.defineProperty(exports, "model", { enumerable: true, get: function () { return decorators_1.model; } });
|
|
90
103
|
Object.defineProperty(exports, "column", { enumerable: true, get: function () { return decorators_1.column; } });
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["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OAAA;AAClB,qHAAA,4BAA4B,OAAA;AAC5B,oHAAA,2BAA2B,OAAA;AAG7B,+CAA+C;AAC/C,mBAAmB;AACnB,+CAA+C;AAE/C,qCAQmB;AAPjB,yGAAA,cAAc,OAAA;AACd,+GAAA,oBAAoB,OAAA;AACpB,uGAAA,YAAY,OAAA;AACZ,6GAAA,kBAAkB,OAAA"}
|
package/docs/BENCHMARK.md
CHANGED
|
@@ -27,52 +27,52 @@ Reference: [Kysely performance comparison article](https://izanami.dev/post/1e3f
|
|
|
27
27
|
<!--@embedoc:benchmark_table-->
|
|
28
28
|
| Operation | litedbmodel | Kysely | Drizzle | TypeORM | Prisma |
|
|
29
29
|
| --- | --- | --- | --- | --- | --- |
|
|
30
|
-
| Find all (limit 100) | 0.
|
|
31
|
-
| Filter, paginate & sort | **0.
|
|
32
|
-
| Nested find all (include posts) | 3.
|
|
33
|
-
| Find first | 0.
|
|
34
|
-
| Nested find first (include posts) | 0.
|
|
35
|
-
| Find unique (by email) | 0.29ms |
|
|
36
|
-
| Nested find unique (include posts) |
|
|
37
|
-
| Create |
|
|
38
|
-
| Nested create (with post) |
|
|
39
|
-
| Update | **0.
|
|
40
|
-
| Nested update (update user + post) |
|
|
41
|
-
| Upsert | 0.
|
|
42
|
-
| Nested upsert (user + post) | **
|
|
43
|
-
| Delete | **0.
|
|
44
|
-
| Create Many (10 records) | 0.
|
|
45
|
-
| Upsert Many (10 records) |
|
|
46
|
-
| Update Many (10 different values) | **0.
|
|
47
|
-
| Nested relations (100→1000→10000) |
|
|
48
|
-
| Nested relations (composite key, 5 tenants) |
|
|
30
|
+
| Find all (limit 100) | 0.70ms | 0.65ms | **0.64ms** 🏆 | 0.72ms | 1.35ms |
|
|
31
|
+
| Filter, paginate & sort | **0.58ms** 🏆 | 0.64ms | 0.59ms | 0.66ms | 1.10ms |
|
|
32
|
+
| Nested find all (include posts) | **3.64ms** 🏆 | 4.60ms | 4.66ms | 8.34ms | 12.06ms |
|
|
33
|
+
| Find first | 0.37ms | **0.32ms** 🏆 | 0.36ms | 0.40ms | 0.59ms |
|
|
34
|
+
| Nested find first (include posts) | 0.65ms | 0.61ms | 0.71ms | **0.52ms** 🏆 | 1.06ms |
|
|
35
|
+
| Find unique (by email) | **0.29ms** 🏆 | 0.31ms | 0.30ms | 0.32ms | 0.53ms |
|
|
36
|
+
| Nested find unique (include posts) | **0.57ms** 🏆 | 0.58ms | 0.59ms | 1.05ms | 0.94ms |
|
|
37
|
+
| Create | 0.69ms | **0.68ms** 🏆 | 0.76ms | 0.79ms | 1.01ms |
|
|
38
|
+
| Nested create (with post) | **0.90ms** 🏆 | 0.96ms | 1.03ms | 1.22ms | 1.81ms |
|
|
39
|
+
| Update | 0.63ms | **0.61ms** 🏆 | 0.66ms | 0.67ms | 1.12ms |
|
|
40
|
+
| Nested update (update user + post) | 0.94ms | 1.00ms | **0.92ms** 🏆 | 1.02ms | 2.28ms |
|
|
41
|
+
| Upsert | 0.71ms | 0.74ms | **0.66ms** 🏆 | 0.75ms | 2.07ms |
|
|
42
|
+
| Nested upsert (user + post) | **1.00ms** 🏆 | **1.00ms** 🏆 | **1.00ms** 🏆 | 1.14ms | 2.27ms |
|
|
43
|
+
| Delete | **0.97ms** 🏆 | 1.00ms | 0.98ms | 1.10ms | 1.72ms |
|
|
44
|
+
| Create Many (10 records) | 0.77ms | **0.72ms** 🏆 | 0.89ms | 1.00ms | 1.20ms |
|
|
45
|
+
| Upsert Many (10 records) | **0.88ms** 🏆 | 0.90ms | 1.03ms | 1.06ms | 11.89ms |
|
|
46
|
+
| Update Many (10 different values) | **0.70ms** 🏆 | 2.83ms | 2.75ms | 3.02ms | 5.31ms |
|
|
47
|
+
| Nested relations (100→1000→10000) | 25.82ms | 24.65ms | **24.25ms** 🏆 | 80.56ms | 84.10ms |
|
|
48
|
+
| Nested relations (composite key, 5 tenants) | 22.41ms | N/A | **16.26ms** 🏆 | 39.25ms | 219.00ms |
|
|
49
49
|
<!--@embedoc:end-->
|
|
50
50
|
|
|
51
51
|
*All write operations wrapped in transactions for fair comparison across all ORMs.*
|
|
52
52
|
|
|
53
53
|
### Analysis
|
|
54
54
|
|
|
55
|
-
1. **litedbmodel** - **Fastest in write operations** 🏆
|
|
56
|
-
- **#1 in Filter/paginate,
|
|
57
|
-
- Update Many with different values: **3.
|
|
55
|
+
1. **litedbmodel** - **Fastest in read/write operations** 🏆
|
|
56
|
+
- **#1 in Filter/paginate, Nested find all, Find unique, Nested find unique, Nested create, Nested upsert (tie), Delete, Upsert Many, Update Many**
|
|
57
|
+
- Update Many with different values: **3.9x - 7.6x faster** than other ORMs
|
|
58
58
|
- Excellent balance of read and write performance
|
|
59
59
|
|
|
60
60
|
2. **Kysely** - **Strong simple query performance**
|
|
61
|
-
- **#1 in Find
|
|
61
|
+
- **#1 in Find first, Create, Update, Create Many**
|
|
62
62
|
- Minimal abstraction overhead
|
|
63
63
|
- **Limitation:** Cannot batch load composite FK
|
|
64
64
|
|
|
65
65
|
3. **Drizzle** - **Fastest in nested relations** 🏆
|
|
66
|
-
- **#1 in Find all
|
|
66
|
+
- **#1 in Find all, Nested update, Upsert, Nested upsert (tie), Nested relations single key (24ms), Nested composite key (16ms)** using LATERAL JOIN
|
|
67
67
|
- Query API with relations provides excellent performance
|
|
68
68
|
|
|
69
69
|
4. **TypeORM** - Variable performance
|
|
70
|
-
- **#1 in
|
|
71
|
-
- Decent composite key support (
|
|
70
|
+
- **#1 in Nested find first** (JOIN-based approach)
|
|
71
|
+
- Decent composite key support (39ms)
|
|
72
72
|
|
|
73
73
|
5. **Prisma** - Convenience over speed
|
|
74
74
|
- **Slowest in most operations** (1.5x - 14x slower)
|
|
75
|
-
- Composite key nested:
|
|
75
|
+
- Composite key nested: 219ms (**13x slower** than Drizzle)
|
|
76
76
|
- Trade-off: Rich DX features (Prisma Studio, migrations, etc.)
|
|
77
77
|
|
|
78
78
|
---
|
|
@@ -89,33 +89,33 @@ Reference: [Kysely performance comparison article](https://izanami.dev/post/1e3f
|
|
|
89
89
|
|
|
90
90
|
| ORM | Median | Ratio | Queries | Notes |
|
|
91
91
|
|-----|--------|-------|---------|-------|
|
|
92
|
-
| **Drizzle** 🏆 | **
|
|
93
|
-
| Kysely |
|
|
94
|
-
| litedbmodel |
|
|
95
|
-
| TypeORM |
|
|
96
|
-
| Prisma |
|
|
92
|
+
| **Drizzle** 🏆 | **24.25ms** | **1.00x** | 1 | **LATERAL JOIN** |
|
|
93
|
+
| Kysely | 24.65ms | 1.02x | 3 | Separate queries |
|
|
94
|
+
| litedbmodel | 25.82ms | 1.06x | 3 | Separate queries + sync cache |
|
|
95
|
+
| TypeORM | 80.56ms | 3.32x | 2 | JOIN-based |
|
|
96
|
+
| Prisma | 84.10ms | 3.47x | 3 | Parameter explosion |
|
|
97
97
|
|
|
98
98
|
### Composite Key Relations (5 tenants × 100 users)
|
|
99
99
|
|
|
100
100
|
| ORM | Median | Ratio | Queries | Notes |
|
|
101
101
|
|-----|--------|-------|---------|-------|
|
|
102
|
-
| **Drizzle** 🏆 | **
|
|
103
|
-
| litedbmodel |
|
|
104
|
-
| TypeORM |
|
|
105
|
-
| Prisma |
|
|
102
|
+
| **Drizzle** 🏆 | **16.26ms** | **1.00x** | 1 | **LATERAL JOIN with composite** |
|
|
103
|
+
| litedbmodel | 22.41ms | 1.38x | 3 | unnest + JOIN |
|
|
104
|
+
| TypeORM | 39.25ms | 2.41x | 2 | Multiple OR conditions |
|
|
105
|
+
| Prisma | 219.00ms | 13.47x | 3 | Parameter explosion (2000+ params) |
|
|
106
106
|
| Kysely | N/A | - | - | Cannot batch composite FK |
|
|
107
107
|
|
|
108
108
|
### Deep Nested Analysis
|
|
109
109
|
|
|
110
110
|
**Single Key:**
|
|
111
|
-
- Drizzle fastest with LATERAL JOIN (
|
|
112
|
-
- Kysely close (
|
|
113
|
-
- litedbmodel (
|
|
111
|
+
- Drizzle fastest with LATERAL JOIN (24ms)
|
|
112
|
+
- Kysely close (25ms) with 3 separate queries
|
|
113
|
+
- litedbmodel (26ms, 1.06x) with 3 separate queries
|
|
114
114
|
|
|
115
115
|
**Composite Key (multi-tenant):**
|
|
116
116
|
- **Drizzle fastest (16ms)** with LATERAL JOIN query API
|
|
117
|
-
- litedbmodel 1.
|
|
118
|
-
- Prisma
|
|
117
|
+
- litedbmodel 1.38x (22ms) with `unnest + JOIN` approach
|
|
118
|
+
- Prisma 13x slower with 2000+ parameters
|
|
119
119
|
- **Kysely cannot batch load composite FK** (would require manual tuple matching)
|
|
120
120
|
|
|
121
121
|
> **Drizzle advantage:** LATERAL JOIN provides fastest nested relation loading for both single and composite keys when using the query API with relations.
|
|
@@ -538,11 +538,11 @@ WHERE (tenant_id, user_id) IN (($1,$2),($3,$4),...,($1999,$2000))
|
|
|
538
538
|
|
|
539
539
|
| Scenario | Best Fit | Notes |
|
|
540
540
|
|----------|----------|-------|
|
|
541
|
-
| Write operations (transactions) | **litedbmodel** | Fastest in
|
|
542
|
-
| Bulk Update (diff values) | **litedbmodel** | **3.
|
|
543
|
-
| Nested find all | **litedbmodel** | Fastest at 3.
|
|
544
|
-
| Nested single key (speed) | Drizzle | 1 query via LATERAL JOIN (
|
|
545
|
-
| Nested composite key (speed) |
|
|
541
|
+
| Write operations (transactions) | **litedbmodel** | Fastest in Nested create, Delete, Upsert Many, etc. |
|
|
542
|
+
| Bulk Update (diff values) | **litedbmodel** | **3.9x - 7.6x faster** than others (single query) |
|
|
543
|
+
| Nested find all | **litedbmodel** | Fastest at 3.64ms |
|
|
544
|
+
| Nested single key (speed) | Drizzle | 1 query via LATERAL JOIN (24ms) |
|
|
545
|
+
| Nested composite key (speed) | Drizzle | 16ms via LATERAL JOIN |
|
|
546
546
|
| Nested relation SQL quality | **litedbmodel** | Readable + debuggable; stable query patterns (PG) |
|
|
547
547
|
| Log Analysis / Monitoring | **litedbmodel** | Consistent query patterns |
|
|
548
548
|
| SQL Fingerprint Stability (PG) | **litedbmodel** | Most predictable in prepared-statement setups |
|
|
@@ -550,14 +550,14 @@ WHERE (tenant_id, user_id) IN (($1,$2),($3,$4),...,($1999,$2000))
|
|
|
550
550
|
| Data Integrity | **litedbmodel** | Explicit transactions required for writes |
|
|
551
551
|
|
|
552
552
|
**litedbmodel excels at:**
|
|
553
|
-
- **
|
|
554
|
-
- **
|
|
555
|
-
- **
|
|
553
|
+
- **Read operations** (Find unique, Nested find unique, Nested find all - all fastest)
|
|
554
|
+
- **Write operations** (Nested create, Delete, Upsert Many, Update Many - fastest)
|
|
555
|
+
- **Bulk update with different values** (3.9x - 7.6x faster)
|
|
556
556
|
- **Consistent performance** across all operations
|
|
557
557
|
- **Data integrity** via required transactions
|
|
558
558
|
|
|
559
|
-
**vs Prisma:** litedbmodel is **1.
|
|
560
|
-
**vs Query Builders:** litedbmodel
|
|
559
|
+
**vs Prisma:** litedbmodel is **1.5x - 13.5x faster** across operations
|
|
560
|
+
**vs Query Builders:** litedbmodel matches or beats Kysely/Drizzle in most operations
|
|
561
561
|
|
|
562
562
|
> **litedbmodel provides best-in-class performance with safety guarantees:**
|
|
563
563
|
> - Type-safe column symbols (IDE refactoring)
|
|
@@ -569,6 +569,6 @@ WHERE (tenant_id, user_id) IN (($1,$2),($3,$4),...,($1999,$2000))
|
|
|
569
569
|
|
|
570
570
|
---
|
|
571
571
|
|
|
572
|
-
*Last updated:
|
|
572
|
+
*Last updated: March 2026*
|
|
573
573
|
*Benchmark methodology: Based on [Prisma orm-benchmarks](https://github.com/prisma/orm-benchmarks)*
|
|
574
574
|
|
package/docs/COMPARISON.md
CHANGED
|
@@ -12,7 +12,7 @@ A detailed comparison of litedbmodel with popular TypeScript/JavaScript ORMs.
|
|
|
12
12
|
| | Migrations | Manual | Manual | Kit (optional) | Built-in | Built-in | Built-in | Built-in | Knex |
|
|
13
13
|
| **Query API** | Primary query style | Tuple array | Fluent QB | Fluent QB | QB / Find | Fluent client | QB / EM | Fluent | Fluent |
|
|
14
14
|
| | Raw SQL escape hatch† | ✅ `query()` | ⚠️ `sql` | ⚠️ `sql` | ⚠️ `query()` | ⚠️ `$queryRaw` | ⚠️ `execute()` | ⚠️ `query()` | ⚠️ `raw()` |
|
|
15
|
-
| **Type Safety**†† | Compile-time type safety |
|
|
15
|
+
| **Type Safety**†† | Compile-time type safety | ✅ | ✅ | ✅ | ⚠️ partial | ✅ | ⚠️ partial | ❌ runtime-heavy | ⚠️ partial |
|
|
16
16
|
| **Column Refs**‡ | How columns are referenced | **Symbols** | String literals | Column objects | Strings/decorators | Object keys | Strings | Strings | Strings |
|
|
17
17
|
| **IDE Support**§ | Refactoring safety (IDE) | ✅ Full | ❌ | ⚠️ Partial | ❌ | ❌ | ❌ | ❌ | ❌ |
|
|
18
18
|
| **Updates** | Declarative partial update | ✅ **SKIP** | ❌ manual | ❌ manual | ❌ manual | ⚠️ `undefined` | ❌ manual | ❌ manual | ❌ manual |
|
|
@@ -52,7 +52,8 @@ Whether the *tool's standard relation API* fetches nested relations in a single
|
|
|
52
52
|
|
|
53
53
|
**†† Type safety (litedbmodel):**
|
|
54
54
|
- `[Column, value]` tuples: **Compile-time** type checking via Column symbols
|
|
55
|
-
-
|
|
55
|
+
- ``sql`` tagged template conditions (``[sql`${Col} > ?`, val]``): **Compile-time** type checking — the ``sql`` tag preserves the Column's value type
|
|
56
|
+
- ESLint plugin provides additional SQL syntax and cross-model validation
|
|
56
57
|
|
|
57
58
|
**\*\* DB portability:**
|
|
58
59
|
- **Multi-DB** = databases the tool can talk to
|
|
@@ -106,6 +107,7 @@ class UserModel extends DBModel {
|
|
|
106
107
|
}
|
|
107
108
|
|
|
108
109
|
// Migrations: Manual SQL files
|
|
110
|
+
// Code generation: litedbmodel-gen generates @column() from schema.sql (optional)
|
|
109
111
|
```
|
|
110
112
|
|
|
111
113
|
### Prisma
|
|
@@ -156,7 +158,7 @@ drizzle-kit generate:pg
|
|
|
156
158
|
|---------|-------------|--------|---------|---------|--------|
|
|
157
159
|
| **Schema Format** | TS Decorators | Prisma DSL | TS Decorators | TS Schema | TS Interface |
|
|
158
160
|
| **Migration Tool** | Manual | Built-in | Built-in | drizzle-kit | Manual |
|
|
159
|
-
| **Auto-Generate** |
|
|
161
|
+
| **Auto-Generate** | ⚠️ [litedbmodel-gen](https://www.npmjs.com/package/litedbmodel-gen) | ✅ | ✅ | ✅ | ❌ |
|
|
160
162
|
| **Reversible** | Manual | ✅ | ✅ | ⚠️ | Manual |
|
|
161
163
|
|
|
162
164
|
---
|
|
@@ -175,7 +177,7 @@ const users = await User.find([
|
|
|
175
177
|
[User.is_active, true],
|
|
176
178
|
User.or(
|
|
177
179
|
[[User.role, 'admin']],
|
|
178
|
-
[[User.role, 'moderator'], [`${User.level} >= ?`, 5]],
|
|
180
|
+
[[User.role, 'moderator'], [sql`${User.level} >= ?`, 5]],
|
|
179
181
|
),
|
|
180
182
|
]);
|
|
181
183
|
|
|
@@ -352,7 +354,7 @@ const users = await User.query(`
|
|
|
352
354
|
| Scenario | litedbmodel | Query Builder ORMs |
|
|
353
355
|
|----------|-------------|-------------------|
|
|
354
356
|
| **Simple CRUD** | Tuple API: `[[User.name, 'John']]` | Object: `{ name: 'John' }` |
|
|
355
|
-
| **Complex WHERE** |
|
|
357
|
+
| **Complex WHERE** | `sql` tag: `` [sql`${User.age} > ?`, 18] `` | DSL methods: `.where('age', '>', 18)` |
|
|
356
358
|
| **JOINs, CTEs** | Real SQL via `query()` or Query-Based Models | Limited DSL or raw escape |
|
|
357
359
|
| **Debugging** | See actual SQL | Translate DSL → SQL mentally |
|
|
358
360
|
| **Learning** | Know SQL = Ready | Learn DSL + SQL |
|
|
@@ -369,9 +371,9 @@ const users = await User.query(`
|
|
|
369
371
|
|
|
370
372
|
## 5. Type Safety
|
|
371
373
|
|
|
372
|
-
### litedbmodel - Compile-time (Column Symbols)
|
|
374
|
+
### litedbmodel - Compile-time (Column Symbols + `sql` Tag)
|
|
373
375
|
|
|
374
|
-
Type derived from decorators, checked via Column symbol references.
|
|
376
|
+
Type derived from decorators, checked via Column symbol references and `sql` tagged template.
|
|
375
377
|
|
|
376
378
|
```typescript
|
|
377
379
|
// Compile-time validation via Column symbols
|
|
@@ -383,8 +385,9 @@ await User.create([
|
|
|
383
385
|
|
|
384
386
|
// Conditions also type-checked
|
|
385
387
|
await User.find([
|
|
386
|
-
[User.id, 1],
|
|
387
|
-
[`${User.age} > ?`, 18],
|
|
388
|
+
[User.id, 1], // ✅ Compile-time (Column symbol)
|
|
389
|
+
[sql`${User.age} > ?`, 18], // ✅ Compile-time (sql tag preserves Column value type)
|
|
390
|
+
// [sql`${User.age} > ?`, 'x'], // ❌ Compile error (string not assignable to number)
|
|
388
391
|
]);
|
|
389
392
|
```
|
|
390
393
|
|
|
@@ -475,13 +478,14 @@ const users = await db
|
|
|
475
478
|
| Feature | litedbmodel | Prisma | TypeORM | Drizzle | Kysely |
|
|
476
479
|
|---------|-------------|--------|---------|---------|--------|
|
|
477
480
|
| **Type Source** | Decorators → Symbols | .prisma → Generated | Decorators | TS Schema | TS Interface |
|
|
478
|
-
| **Condition Check** | ✅ Full
|
|
481
|
+
| **Condition Check** | ✅ Full | ✅ Full | ⚠️ Partial | ✅ Full | ✅ Full |
|
|
479
482
|
| **Result Types** | ✅ Model types | ✅ Generated | ✅ Entity types | ✅ Inferred | ✅ Inferred |
|
|
480
|
-
| **Compile-Time** |
|
|
483
|
+
| **Compile-Time** | ✅ Full† | ✅ | ⚠️ | ✅ | ✅ |
|
|
481
484
|
|
|
482
|
-
*† litedbmodel's type safety
|
|
485
|
+
*† litedbmodel's compile-time type safety covers both patterns:*
|
|
483
486
|
- *`[Column, value]` tuples: Compile-time type checking via Column symbols*
|
|
484
|
-
-
|
|
487
|
+
- *`[sql\`${Col} > ?\`, val]` tuples: Compile-time type checking — the `sql` tag preserves the Column's value type*
|
|
488
|
+
- *ESLint plugin provides additional SQL syntax validation and cross-model column checking*
|
|
485
489
|
|
|
486
490
|
---
|
|
487
491
|
|
|
@@ -1073,13 +1077,13 @@ For detailed benchmark results comparing litedbmodel with Prisma, Kysely, Drizzl
|
|
|
1073
1077
|
|
|
1074
1078
|
| Operation Type | litedbmodel Performance |
|
|
1075
1079
|
|----------------|------------------------|
|
|
1076
|
-
| Standard CRUD | **Fastest in
|
|
1077
|
-
| Nested relations | Competitive (within
|
|
1078
|
-
| Deep nested (10K) |
|
|
1080
|
+
| Standard CRUD | **Fastest in 9/19 operations** (Filter/sort, Nested find all, Find unique, Nested find unique, Nested create, Delete, Upsert Many, Update Many, etc.) |
|
|
1081
|
+
| Nested relations | Competitive (within 6% of fastest) |
|
|
1082
|
+
| Deep nested (10K) | 3.3x faster than Prisma |
|
|
1079
1083
|
| SQL quality | ⭐⭐⭐⭐⭐ (readable, fixed params on PG) |
|
|
1080
1084
|
|
|
1081
|
-
**vs Prisma:** litedbmodel is **1.
|
|
1082
|
-
**vs Query Builders:** litedbmodel
|
|
1085
|
+
**vs Prisma:** litedbmodel is **1.5x - 13.5x faster** across all operations
|
|
1086
|
+
**vs Query Builders:** litedbmodel matches or beats Kysely/Drizzle in most operations
|
|
1083
1087
|
|
|
1084
1088
|
---
|
|
1085
1089
|
|
|
@@ -1152,13 +1156,14 @@ For detailed benchmark results comparing litedbmodel with Prisma, Kysely, Drizzl
|
|
|
1152
1156
|
### litedbmodel's Characteristics
|
|
1153
1157
|
|
|
1154
1158
|
1. **Symbol-Based Columns**: IDE "Find References" and "Rename Symbol" work
|
|
1155
|
-
2.
|
|
1156
|
-
3. **
|
|
1157
|
-
4. **
|
|
1158
|
-
5. **
|
|
1159
|
-
6. **
|
|
1160
|
-
7. **
|
|
1161
|
-
8. **
|
|
1159
|
+
2. **`sql` Tagged Template**: Type-safe operator conditions and parameterized queries
|
|
1160
|
+
3. **SKIP Sentinel**: Declarative conditional fields without if-statements
|
|
1161
|
+
4. **Minimal Footprint**: 60KB minified, no binary dependencies
|
|
1162
|
+
5. **Middleware**: Cross-cutting concern support (logging, auth, metrics)
|
|
1163
|
+
6. **Auto N+1 Prevention**: Batch loading enabled automatically for multiple records
|
|
1164
|
+
7. **Composite Key Support**: Full support for composite keys in relations
|
|
1165
|
+
8. **Fixed SQL Parameters**: `ANY()` and `unnest()` keep parameter count constant
|
|
1166
|
+
9. **Readable SQL**: Simple, debuggable queries (no hash aliases or deep nesting)
|
|
1162
1167
|
|
|
1163
1168
|
### Trade-offs
|
|
1164
1169
|
|