jsql-neo 6.8.26 → 6.9.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
@@ -3,7 +3,7 @@
3
3
  > **One engine to rule them all** — a Rust-powered embedded database that speaks your language:
4
4
  > MySQL, PostgreSQL, MongoDB, Redis, SQL, TypeScript, **and the browser**.
5
5
 
6
- > **v6.8.26** — stable release · [github.com/vexify-org/JSQL-neo](https://github.com/vexify-org/JSQL-neo) · [jsql.vexify.top](https://jsql.vexify.top)
6
+ > **v6.9.0** — stable release · [github.com/vexify-org/JSQL-neo](https://github.com/vexify-org/JSQL-neo) · [jsql.vexify.top](https://jsql.vexify.top)
7
7
 
8
8
  ![Engines](https://img.shields.io/badge/engines-Native%20%7C%20WASM%20%7C%20Pure%20JS-7ee787)
9
9
  ![MySQL](https://img.shields.io/badge/protocol-MySQL%20compatible-1f6feb)
@@ -172,9 +172,12 @@ await db.start();
172
172
  File mode (`new Database('./data/db.json')`) is **not** an in-memory store that only
173
173
  writes on exit. Every `insert` / `insertMany` / `update` / `updateById` / `remove` /
174
174
  `removeById` / `softDelete` / `truncate` appends one JSONL record to `<file>.wal` and
175
- `fsync`s it before returning, so a `kill -9` loses nothing that already committed.
176
- `save()` / `close()` / `stop()` only checkpoint (write a full snapshot, then truncate
177
- the WAL); they are no longer the moment data first reaches disk.
175
+ writes it to the kernel before returning, so a `kill -9` loses nothing that already
176
+ committed. `fsync` is coalesced into a short window (`walSyncInterval`, default 20 ms)
177
+ so bulk single-row writes no longer pay one disk flush per row — set it to `0` for the
178
+ strictest per-write `fsync` behaviour (roughly an order of magnitude slower).
179
+ `save()` / `close()` / `stop()` checkpoint the WAL (write a full snapshot, `fsync`, then
180
+ truncate) and always flush any pending window first.
178
181
  WAL is on by default for file mode — pass `wal: false` for the old semantics, or tune
179
182
  auto-checkpointing with `walCheckpointOps` (default 1000, `0` disables). Directory
180
183
  (`mode: 'disk' | 'hybrid'`) and encrypted (`encryptKey`) databases keep it off unless
package/index.d.ts CHANGED
@@ -295,6 +295,7 @@ declare namespace JSQLNeo {
295
295
  allowComments?: boolean;
296
296
  safety?: boolean;
297
297
  maxStatements?: number;
298
+ allowStacked?: boolean;
298
299
  session?: Record<string, unknown>;
299
300
  /** 5.5.0+:原生 `?` 占位符绑定值(与 applyParams 的数组入参二选一) */
300
301
  params?: unknown[];
@@ -334,13 +335,30 @@ declare namespace JSQLNeo {
334
335
  export function transform(ast: unknown, fn: (node: unknown) => unknown): unknown;
335
336
 
336
337
  export interface DatabaseOptions {
337
- dataDir?: string;
338
- persist?: boolean;
339
- inMemoryOnly?: boolean;
338
+ mode?: 'memory' | 'hybrid' | 'disk';
339
+ autoSave?: boolean;
340
+ autoSaveInterval?: number;
341
+ memReserveMB?: number;
342
+ flushInterval?: number;
343
+ evictInterval?: number;
344
+ encryptKey?: string;
345
+ versioning?: boolean;
346
+ wal?: boolean;
347
+ walCheckpointOps?: number;
348
+ walSyncInterval?: number;
349
+ isolationLevel?: 'READ_COMMITTED' | 'REPEATABLE_READ';
350
+ slowQueryThreshold?: number;
351
+ fileLock?: boolean;
352
+ }
353
+
354
+ export interface DatastoreOptions {
355
+ filename?: string;
356
+ database?: unknown;
357
+ engine?: unknown;
340
358
  }
341
359
 
342
360
  export class Database {
343
- constructor(options?: DatabaseOptions);
361
+ constructor(filePath?: string, options?: DatabaseOptions);
344
362
  createTable(name: string, schema: Schema): Promise<unknown>;
345
363
  insert(table: string, data: Record<string, unknown>): Promise<unknown>;
346
364
  find(table: string, filter?: Record<string, unknown>): Promise<Row[]>;
@@ -424,7 +442,7 @@ declare namespace JSQLNeo {
424
442
  }
425
443
 
426
444
  export class Datastore {
427
- constructor(options?: DatabaseOptions);
445
+ constructor(options?: DatastoreOptions);
428
446
  insert(docs: unknown): Promise<unknown>;
429
447
  find(query?: unknown): Promise<unknown[]>;
430
448
  update(query: unknown, update: unknown): Promise<number>;
package/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * JSQL-NEO v6.8.26 — Rust-Powered Embedded Database (WASM + HTTP)
2
+ * JSQL-NEO v6.9.0 — Rust-Powered Embedded Database (WASM + HTTP)
3
3
  *
4
4
  * @example
5
5
  * const jsql = require('jsql-neo');
@@ -14,6 +14,17 @@ function colNameOf(node) {
14
14
  return node.type === 'column' ? node.name : null;
15
15
  }
16
16
 
17
+ /**
18
+ * #469:聚合输出列名,与行存命名规则一致 —— 保留实参 / `*`:
19
+ * COUNT(v)、COUNT(*)、MIN(s),不得退化为 COUNT()。
20
+ */
21
+ function aggLabel(fn, col) {
22
+ let arg;
23
+ if (col == null || col.type === 'star' || col.type === '*') arg = '*';
24
+ else arg = colNameOf(col) || '*';
25
+ return fn + '(' + arg + ')';
26
+ }
27
+
17
28
  /**
18
29
  * 把 WHERE 编译成「命中行下标数组」。
19
30
  * 只支持 `列 OP 字面量` 以及它们的 AND 组合;其它(OR / LIKE / 函数 / 子查询 /
@@ -196,7 +207,7 @@ function aggregate(statement, data) {
196
207
  default: return null;
197
208
  }
198
209
  outRow.push(v);
199
- outCols.push(c.alias || (fn + '()'));
210
+ outCols.push(c.alias || aggLabel(fn, argNode));
200
211
  }
201
212
  return { type: 'select', columns: outCols, rows: [outRow] };
202
213
  }
@@ -339,7 +350,7 @@ function groupBy(statement, data) {
339
350
  outRows.push(row);
340
351
  }
341
352
  const outCols = cols.map(c => c.alias || (c.aggregate
342
- ? String(c.aggregate).toUpperCase() + '()'
353
+ ? aggLabel(String(c.aggregate).toUpperCase(), c.column)
343
354
  : colNameOf(c.scalar || c.expr)));
344
355
 
345
356
  // ORDER BY:在分组结果上排序 —— 组数通常远小于行数,代价很低。