Document typedefs better. Fix tables deletion schema sync issue.
This commit is contained in:
Vendored
+7
@@ -0,0 +1,7 @@
|
||||
import type { BUN_SQLITE_DatabaseSchemaType } from "../types";
|
||||
type Params = {
|
||||
schema: BUN_SQLITE_DatabaseSchemaType;
|
||||
};
|
||||
export declare function writeLiveSchema({ schema }: Params): void;
|
||||
export declare function readLiveSchema(): BUN_SQLITE_DatabaseSchemaType | undefined;
|
||||
export {};
|
||||
Vendored
+15
@@ -0,0 +1,15 @@
|
||||
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "fs";
|
||||
import grabDirNames from "../data/grab-dir-names";
|
||||
import path from "path";
|
||||
const { BUN_SQLITE_LIVE_SCHEMA } = grabDirNames();
|
||||
export function writeLiveSchema({ schema }) {
|
||||
mkdirSync(path.dirname(BUN_SQLITE_LIVE_SCHEMA), { recursive: true });
|
||||
writeFileSync(BUN_SQLITE_LIVE_SCHEMA, JSON.stringify(schema));
|
||||
}
|
||||
export function readLiveSchema() {
|
||||
if (!existsSync(BUN_SQLITE_LIVE_SCHEMA)) {
|
||||
return undefined;
|
||||
}
|
||||
const live_schema = readFileSync(BUN_SQLITE_LIVE_SCHEMA, "utf-8");
|
||||
return JSON.parse(live_schema);
|
||||
}
|
||||
Reference in New Issue
Block a user