neosqlite 1.0.7 → 1.0.9

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.7",
4
+ "version": "1.0.9",
5
5
  "main": "lib/src/index.js",
6
6
  "scripts": {
7
7
  "build": "tsc",
@@ -55,7 +55,7 @@ function createClient(config) {
55
55
  * Batch writes to the database
56
56
  */
57
57
  const batchWrite = (statements) => {
58
- db.transaction(() => {
58
+ transaction(() => {
59
59
  for (const statement of statements) {
60
60
  const query = (0, util_1.parseQuery)(statement);
61
61
  const sqlStatement = db.prepare(query.sql);
@@ -1,11 +1,11 @@
1
1
  import { CreateJobsOptions, JobOptions, NeosqliteClient } from "../types";
2
2
  export declare class NeosqliteJobs {
3
3
  private db;
4
- private options;
4
+ private options?;
5
5
  private jobsRegistry;
6
6
  private activeJobs;
7
7
  private isRunning;
8
- constructor(db: NeosqliteClient, options: CreateJobsOptions);
8
+ constructor(db: NeosqliteClient, options?: CreateJobsOptions | undefined);
9
9
  private get jobsTable();
10
10
  private get maxJobs();
11
11
  private get processEvery();
@@ -18,16 +18,16 @@ class NeosqliteJobs {
18
18
  this.isRunning = false;
19
19
  }
20
20
  get jobsTable() {
21
- return this.options.jobsTable ?? "jobs";
21
+ return this.options?.jobsTable ?? "jobs";
22
22
  }
23
23
  get maxJobs() {
24
- return this.options.maxJobs ?? 10;
24
+ return this.options?.maxJobs ?? 10;
25
25
  }
26
26
  get processEvery() {
27
- return this.options.processEvery ?? 5000;
27
+ return this.options?.processEvery ?? 5000;
28
28
  }
29
29
  get maxRetries() {
30
- return this.options.maxRetries ?? 3;
30
+ return this.options?.maxRetries ?? 3;
31
31
  }
32
32
  /**
33
33
  * Setup tables and start the job worker for neosqlite jobs
@@ -61,7 +61,7 @@ export interface CliCommandOptions extends NeosqliteConfig {
61
61
  /** The name of the table to store migrations in. Defaults to "migrations" */
62
62
  migrationTable?: string;
63
63
  }
64
- export interface CreateJobsOptions extends NeosqliteConfig {
64
+ export interface CreateJobsOptions {
65
65
  /** The name of the table to store jobs in. Defaults to "jobs" */
66
66
  jobsTable?: string;
67
67
  /** How often to process jobs in milliseconds. Defaults to 5000 */
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.7",
4
+ "version": "1.0.9",
5
5
  "main": "lib/src/index.js",
6
6
  "scripts": {
7
7
  "build": "tsc",
@@ -64,7 +64,7 @@ export function createClient(config: NeosqliteConfig): NeosqliteClient {
64
64
  * Batch writes to the database
65
65
  */
66
66
  const batchWrite = (statements: ExecuteQueryParams[]) => {
67
- db.transaction(() => {
67
+ transaction(() => {
68
68
  for (const statement of statements) {
69
69
  const query = parseQuery(statement);
70
70
  const sqlStatement = db.prepare(query.sql);
package/src/jobs/index.ts CHANGED
@@ -20,23 +20,23 @@ export class NeosqliteJobs {
20
20
 
21
21
  constructor(
22
22
  private db: NeosqliteClient,
23
- private options: CreateJobsOptions,
23
+ private options?: CreateJobsOptions,
24
24
  ) {}
25
25
 
26
26
  private get jobsTable() {
27
- return this.options.jobsTable ?? "jobs";
27
+ return this.options?.jobsTable ?? "jobs";
28
28
  }
29
29
 
30
30
  private get maxJobs() {
31
- return this.options.maxJobs ?? 10;
31
+ return this.options?.maxJobs ?? 10;
32
32
  }
33
33
 
34
34
  private get processEvery() {
35
- return this.options.processEvery ?? 5000;
35
+ return this.options?.processEvery ?? 5000;
36
36
  }
37
37
 
38
38
  private get maxRetries() {
39
- return this.options.maxRetries ?? 3;
39
+ return this.options?.maxRetries ?? 3;
40
40
  }
41
41
 
42
42
  /**
package/src/types.ts CHANGED
@@ -81,7 +81,7 @@ export interface CliCommandOptions extends NeosqliteConfig {
81
81
  migrationTable?: string;
82
82
  }
83
83
 
84
- export interface CreateJobsOptions extends NeosqliteConfig {
84
+ export interface CreateJobsOptions {
85
85
  /** The name of the table to store jobs in. Defaults to "jobs" */
86
86
  jobsTable?: string;
87
87
 
package/database.db DELETED
Binary file
package/index.ts DELETED
@@ -1,14 +0,0 @@
1
- import { createClient } from "./src/client";
2
-
3
- const db = createClient({
4
- file: "database.db",
5
- onQueryLog: (log) => {
6
- console.debug(log);
7
- },
8
- });
9
-
10
- db.write("CREATE TABLE IF NOT EXISTS users (id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT)");
11
-
12
- const result = db.readOne("SELECT * FROM users");
13
-
14
- console.log(result);