json-file-database
Version:
Lightweight Database on NodeJS by JSON Files
29 lines (28 loc) • 847 B
TypeScript
/**
* The file for the database to read.
*/
export interface DatabaseFile {
/**
* Reads the content of the file.
* @returns the content.
*/
read(): string;
/**
* Writes the content to the file.
* @param content the content to be written.
*/
write(content: string): void;
}
/**
* Creates a real file in the disk.
* @param path the path of file.
* @returns the file for the database to read.
*/
export declare function createFile(path: string): DatabaseFile;
/**
* Creates a "file" of an object.
* @param obj the content object.
* @param mutable whether the object is mutable, if so, it will be assigned whenever data updates.
* @returns the file for the database to read.
*/
export declare function createObjectFile(obj: object, mutable?: boolean): DatabaseFile;