@zero-server/orm 1.0.1 → 1.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/lib/orm/adapters/sqlite.js +21 -0
- package/lib/orm/audit.js +2 -1
- package/package.json +3 -3
|
@@ -431,6 +431,27 @@ class SqliteAdapter extends BaseSqlAdapter
|
|
|
431
431
|
{
|
|
432
432
|
const { action, table, fields, where, orderBy, limit, offset, distinct, joins, groupBy, having } = descriptor;
|
|
433
433
|
|
|
434
|
+
// Raw SQL passthrough (e.g. AuditLog.install() issues DDL this way).
|
|
435
|
+
if (descriptor.raw)
|
|
436
|
+
{
|
|
437
|
+
const stmt = this._db.prepare(descriptor.raw);
|
|
438
|
+
return stmt.reader ? stmt.all(...(descriptor.params || [])) : stmt.run(...(descriptor.params || []));
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
// Row insert descriptor (e.g. AuditLog entry writes).
|
|
442
|
+
if (action === 'insert')
|
|
443
|
+
{
|
|
444
|
+
return this.insert(table, descriptor.data);
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
// Conditional delete descriptor (e.g. AuditLog.purge()).
|
|
448
|
+
if (action === 'delete')
|
|
449
|
+
{
|
|
450
|
+
const { clause, values } = this._buildWhereFromChain(where);
|
|
451
|
+
const result = this._prepare(`DELETE FROM "${table}"${clause}`).run(...values);
|
|
452
|
+
return result.changes;
|
|
453
|
+
}
|
|
454
|
+
|
|
434
455
|
if (action === 'count')
|
|
435
456
|
{
|
|
436
457
|
const { clause, values } = this._buildWhereFromChain(where);
|
package/lib/orm/audit.js
CHANGED
|
@@ -465,7 +465,8 @@ class AuditLog
|
|
|
465
465
|
action: 'find',
|
|
466
466
|
table: this.tableName,
|
|
467
467
|
where,
|
|
468
|
-
|
|
468
|
+
// Adapters read the canonical `dir` key ('ASC' | 'DESC').
|
|
469
|
+
orderBy: [{ field: 'timestamp', dir: String(order).toUpperCase() === 'ASC' ? 'ASC' : 'DESC' }],
|
|
469
470
|
limit,
|
|
470
471
|
offset,
|
|
471
472
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zero-server/orm",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "Database, Model, Query, migrations, seeds, search, geo, tenancy, audit.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"zero-server",
|
|
@@ -45,10 +45,10 @@
|
|
|
45
45
|
},
|
|
46
46
|
"sideEffects": false,
|
|
47
47
|
"dependencies": {
|
|
48
|
-
"@zero-server/errors": "1.0
|
|
48
|
+
"@zero-server/errors": "1.1.0"
|
|
49
49
|
},
|
|
50
50
|
"peerDependencies": {
|
|
51
|
-
"@zero-server/sdk": ">=1.0
|
|
51
|
+
"@zero-server/sdk": ">=1.1.0"
|
|
52
52
|
},
|
|
53
53
|
"peerDependenciesMeta": {
|
|
54
54
|
"@zero-server/sdk": {
|