@petradb/engine 1.1.1 → 1.2.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.
Files changed (4) hide show
  1. package/README.md +12 -0
  2. package/index.d.ts +16 -0
  3. package/main.js +61653 -47143
  4. package/package.json +2 -2
package/README.md CHANGED
@@ -24,6 +24,18 @@ const [{ rows }] = await db.execute('SELECT * FROM users');
24
24
  console.log(rows); // [{ id: 1, name: 'Alice', email: 'alice@example.com' }]
25
25
  ```
26
26
 
27
+ ### Persistent Storage
28
+
29
+ Data survives restarts with crash-safe durable storage in a single file:
30
+
31
+ ```javascript
32
+ const db = new Session({ storage: 'persistent', path: './mydb' });
33
+ // ... use the database ...
34
+ db.close();
35
+ ```
36
+
37
+ Also available: `{ storage: 'text', path: './data.ptxt' }` for human-readable text files.
38
+
27
39
  ## Documentation
28
40
 
29
41
  Full documentation, SQL reference, and API details are available at **[petradb.dev](https://petradb.dev)**.
package/index.d.ts CHANGED
@@ -1,5 +1,8 @@
1
1
  export interface SessionOptions {
2
2
  rowMode?: 'object' | 'array';
3
+ storage?: 'memory' | 'persistent' | 'text';
4
+ path?: string;
5
+ pageSize?: number;
3
6
  }
4
7
 
5
8
  export interface ExecuteOptions {
@@ -50,6 +53,16 @@ export interface AlterTableResult {
50
53
  command: 'alter table';
51
54
  }
52
55
 
56
+ export interface CreateViewResult {
57
+ command: 'create view';
58
+ view: string;
59
+ }
60
+
61
+ export interface DropViewResult {
62
+ command: 'drop view';
63
+ view: string;
64
+ }
65
+
53
66
  export interface PrepareResult {
54
67
  command: 'prepare';
55
68
  name: string;
@@ -104,6 +117,8 @@ export type ExecuteResult =
104
117
  | DropIndexResult
105
118
  | TruncateTableResult
106
119
  | AlterTableResult
120
+ | CreateViewResult
121
+ | DropViewResult
107
122
  | InsertResult
108
123
  | SelectResult
109
124
  | UpdateResult
@@ -122,4 +137,5 @@ export class Session {
122
137
  constructor(options?: SessionOptions);
123
138
  execute(sql: string, options?: ExecuteOptions): Promise<ExecuteResult[]>;
124
139
  prepare(sql: string): PreparedStatement;
140
+ close(): void;
125
141
  }