neosqlite 1.0.6 → 1.0.8

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.6",
4
+ "version": "1.0.8",
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
- import { CreateJobsOptions, JobOptions } from "../types";
1
+ import { CreateJobsOptions, JobOptions, NeosqliteClient } from "../types";
2
2
  export declare class NeosqliteJobs {
3
3
  private db;
4
4
  private options;
5
5
  private jobsRegistry;
6
6
  private activeJobs;
7
7
  private isRunning;
8
- constructor(options: CreateJobsOptions);
8
+ constructor(db: NeosqliteClient, options: CreateJobsOptions);
9
9
  private get jobsTable();
10
10
  private get maxJobs();
11
11
  private get processEvery();
@@ -6,17 +6,16 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.NeosqliteJobs = void 0;
7
7
  const cron_parser_1 = __importDefault(require("cron-parser"));
8
8
  const chrono_node_1 = require("chrono-node");
9
- const client_1 = require("../client");
10
9
  const util_1 = require("../client/util");
11
10
  const types_1 = require("../types");
12
11
  class NeosqliteJobs {
13
- constructor(options) {
12
+ constructor(db, options) {
13
+ this.db = db;
14
+ this.options = options;
14
15
  this.jobsRegistry = {};
15
16
  // Jobs worker information
16
17
  this.activeJobs = 0;
17
18
  this.isRunning = false;
18
- this.options = options;
19
- this.db = (0, client_1.createClient)(options);
20
19
  }
21
20
  get jobsTable() {
22
21
  return this.options.jobsTable ?? "jobs";
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.6",
4
+ "version": "1.0.8",
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
@@ -1,7 +1,6 @@
1
1
  import parser from "cron-parser";
2
2
  import { parseDate } from "chrono-node";
3
3
 
4
- import { createClient } from "../client";
5
4
  import { Jsonify, queryString, toSqliteDateString } from "../client/util";
6
5
  import { CreateJobsOptions, JobOptions, JobStatus, Row, NeosqliteClient } from "../types";
7
6
 
@@ -13,18 +12,16 @@ interface JobRegistryValue {
13
12
  }
14
13
 
15
14
  export class NeosqliteJobs {
16
- private db: NeosqliteClient;
17
- private options: CreateJobsOptions;
18
15
  private jobsRegistry: Record<string, JobRegistryValue> = {};
19
16
 
20
17
  // Jobs worker information
21
18
  private activeJobs = 0;
22
19
  private isRunning = false;
23
20
 
24
- constructor(options: CreateJobsOptions) {
25
- this.options = options;
26
- this.db = createClient(options);
27
- }
21
+ constructor(
22
+ private db: NeosqliteClient,
23
+ private options: CreateJobsOptions,
24
+ ) {}
28
25
 
29
26
  private get jobsTable() {
30
27
  return this.options.jobsTable ?? "jobs";