neosqlite 1.0.9 → 1.0.10

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "neosqlite",
3
3
  "description": "A lightweight wrapper around better-sqlite3 that adds developer-friendly features like job scheduling, migrations, error handling, query logging, SQL utilities, and more",
4
- "version": "1.0.9",
4
+ "version": "1.0.10",
5
5
  "main": "lib/src/index.js",
6
6
  "scripts": {
7
7
  "build": "tsc",
@@ -63,6 +63,12 @@ function createClient(config) {
63
63
  }
64
64
  });
65
65
  };
66
+ /**
67
+ * Executes all of the table creation code, separated by semicolons
68
+ */
69
+ const createTableFromSchema = (string) => {
70
+ return (0, util_1.runQuery)(config, string, () => db.exec(string));
71
+ };
66
72
  return {
67
73
  read,
68
74
  readOne,
@@ -70,6 +76,7 @@ function createClient(config) {
70
76
  batchWrite,
71
77
  transaction,
72
78
  writeReturning,
79
+ createTableFromSchema,
73
80
  pragma: db.pragma.bind(db),
74
81
  backup: db.backup.bind(db),
75
82
  };
@@ -27,6 +27,8 @@ export type NeosqliteClient = {
27
27
  changes: number;
28
28
  lastInsertedRowid: number;
29
29
  };
30
+ /** Create a table from a schema. Takes multiple statements separated by semicolons, with no parameters */
31
+ createTableFromSchema: (string: string) => void;
30
32
  };
31
33
  export type OnQueryFinishData = {
32
34
  /** The query that was executed */
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "neosqlite",
3
3
  "description": "A lightweight wrapper around better-sqlite3 that adds developer-friendly features like job scheduling, migrations, error handling, query logging, SQL utilities, and more",
4
- "version": "1.0.9",
4
+ "version": "1.0.10",
5
5
  "main": "lib/src/index.js",
6
6
  "scripts": {
7
7
  "build": "tsc",
@@ -73,6 +73,13 @@ export function createClient(config: NeosqliteConfig): NeosqliteClient {
73
73
  });
74
74
  };
75
75
 
76
+ /**
77
+ * Executes all of the table creation code, separated by semicolons
78
+ */
79
+ const createTableFromSchema = (string: string) => {
80
+ return runQuery(config, string, () => db.exec(string));
81
+ };
82
+
76
83
  return {
77
84
  read,
78
85
  readOne,
@@ -80,6 +87,7 @@ export function createClient(config: NeosqliteConfig): NeosqliteClient {
80
87
  batchWrite,
81
88
  transaction,
82
89
  writeReturning,
90
+ createTableFromSchema,
83
91
  pragma: db.pragma.bind(db),
84
92
  backup: db.backup.bind(db),
85
93
  };
package/src/types.ts CHANGED
@@ -35,6 +35,9 @@ export type NeosqliteClient = {
35
35
 
36
36
  /** Write data to the database, returns the number of rows affected */
37
37
  write: (params: ExecuteQueryParams) => { changes: number; lastInsertedRowid: number };
38
+
39
+ /** Create a table from a schema. Takes multiple statements separated by semicolons, with no parameters */
40
+ createTableFromSchema: (string: string) => void;
38
41
  };
39
42
 
40
43
  export type OnQueryFinishData = {