Skip to content

Commit 82b0acb

Browse files
committed
Format
1 parent 16babe8 commit 82b0acb

File tree

4 files changed

+33
-33
lines changed

4 files changed

+33
-33
lines changed

packages/node/src/db/BetterSQLite3DBAdapter.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import {
1010
LockContext,
1111
Transaction,
1212
DBLockOptions,
13-
QueryResult,
13+
QueryResult
1414
} from '@powersync/common';
1515
import { Remote } from 'comlink';
1616
import { AsyncResource } from 'node:async_hooks';

packages/node/src/db/PowerSyncDatabase.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import { NodeSQLOpenOptions } from './options.js';
1818

1919
export type NodePowerSyncDatabaseOptions = PowerSyncDatabaseOptions & {
2020
database: DBAdapter | SQLOpenFactory | NodeSQLOpenOptions;
21-
}
21+
};
2222

2323
/**
2424
* A PowerSync database which provides SQLite functionality

packages/node/src/db/options.ts

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
11
import { type Worker } from 'node:worker_threads';
2-
import { SQLOpenOptions } from "@powersync/common";
2+
import { SQLOpenOptions } from '@powersync/common';
33

44
/**
55
* The {@link SQLOpenOptions} available across all PowerSync SDKs for JavaScript extended with
66
* Node.JS-specific options.
77
*/
88
export interface NodeSQLOpenOptions extends SQLOpenOptions {
9-
/**
10-
* The Node.JS SDK will use one worker to run writing queries and additional workers to run reads.
11-
* This option controls how many workers to use for reads.
12-
*/
13-
readWorkers?: number,
14-
/**
15-
* A callback to allow customizing how the Node.JS SDK loads workers. This can be customized to
16-
* use workers at different paths.
17-
*
18-
* @param args The arguments that would otherwise be passed to the {@link Worker} constructor.
19-
* @returns the resolved worker.
20-
*/
21-
openWorker?: (...args: ConstructorParameters<typeof Worker>) => InstanceType<typeof Worker>,
9+
/**
10+
* The Node.JS SDK will use one worker to run writing queries and additional workers to run reads.
11+
* This option controls how many workers to use for reads.
12+
*/
13+
readWorkers?: number;
14+
/**
15+
* A callback to allow customizing how the Node.JS SDK loads workers. This can be customized to
16+
* use workers at different paths.
17+
*
18+
* @param args The arguments that would otherwise be passed to the {@link Worker} constructor.
19+
* @returns the resolved worker.
20+
*/
21+
openWorker?: (...args: ConstructorParameters<typeof Worker>) => InstanceType<typeof Worker>;
2222
}

packages/node/tests/PowerSyncDatabase.test.ts

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -11,32 +11,32 @@ test('validates options', async () => {
1111
schema: AppSchema,
1212
database: {
1313
dbFilename: '/dev/null',
14-
readWorkers: 0,
14+
readWorkers: 0
1515
}
1616
});
1717
await database.init();
1818
}).rejects.toThrowError('Needs at least one worker for reads');
1919
});
2020

2121
test('can customize loading workers', async () => {
22-
const directory = await createTempDir();
23-
const openFunction = vi.fn((...args: ConstructorParameters<typeof Worker>) => new Worker(...args));
24-
25-
const database = new PowerSyncDatabase({
26-
schema: AppSchema,
27-
database: {
28-
dbFilename: 'test.db',
29-
dbLocation: directory,
30-
openWorker: openFunction as any,
31-
readWorkers: 2,
32-
}
33-
});
22+
const directory = await createTempDir();
23+
const openFunction = vi.fn((...args: ConstructorParameters<typeof Worker>) => new Worker(...args));
24+
25+
const database = new PowerSyncDatabase({
26+
schema: AppSchema,
27+
database: {
28+
dbFilename: 'test.db',
29+
dbLocation: directory,
30+
openWorker: openFunction as any,
31+
readWorkers: 2
32+
}
33+
});
3434

35-
await database.get('SELECT 1;'); // Make sure the database is ready and works
36-
expect(openFunction).toHaveBeenCalledTimes(3); // One writer, two readers
37-
await database.close();
35+
await database.get('SELECT 1;'); // Make sure the database is ready and works
36+
expect(openFunction).toHaveBeenCalledTimes(3); // One writer, two readers
37+
await database.close();
3838

39-
onTestFinished(async () => fs.rm(directory, { recursive: true }));
39+
onTestFinished(async () => fs.rm(directory, { recursive: true }));
4040
});
4141

4242
databaseTest('links powersync', async ({ database }) => {

0 commit comments

Comments
 (0)