Skip to content

Commit 5f3a102

Browse files
authored
Support memory db for node (#381)
1 parent e9b28d2 commit 5f3a102

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

node/src/database.ts

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,16 @@ export class NodeDatabase implements DB {
2727
private rollbackHookCallback?: (() => void) | null;
2828

2929
constructor(name: string, location?: string) {
30-
const dbLocation = location || './';
31-
this.dbPath = path.join(dbLocation, name);
32-
33-
// Ensure directory exists
34-
const dir = path.dirname(this.dbPath);
35-
if (!fs.existsSync(dir)) {
36-
fs.mkdirSync(dir, { recursive: true });
30+
this.dbPath = ':memory:'
31+
if(location !== ":memory:") {
32+
const dbLocation = location || './';
33+
this.dbPath = path.join(dbLocation, name);
34+
35+
// Ensure directory exists
36+
const dir = path.dirname(this.dbPath);
37+
if (!fs.existsSync(dir)) {
38+
fs.mkdirSync(dir, { recursive: true });
39+
}
3740
}
3841

3942
this.db = new Database(this.dbPath);

0 commit comments

Comments
 (0)