API @deepkit/filesystem-database
npm install @deepkit/filesystem-database
Allows to use all supported Deepkit ORM databases as a filesystem backend.
Classes
@(entity.name())
export class FileEntity implements FilesystemModel {
path: string & PrimaryKey;
dir: string & Index;
type: FileType;
size: number;
created: Date;
visibility: FileVisibility;
lastModified?: Date;
}
@(entity.name())
export class FileDataEntity {
path: string & PrimaryKey;
data: Uint8Array;
}
export class FilesystemDatabaseAdapter implements FilesystemAdapter {
database: Database;
entityClass: ClassType<FilesystemModel>;
entityDataClass: ClassType<FileDataModel>;
transactional: boolean;
constructor(options: FilesystemOrmOptions);
supportsVisibility();
supportsDirectory();
async close(): Promise<void>;
async makeDirectory(path: string, visibility: FileVisibility, session?: DatabaseSession): Promise<void>;
async setVisibility(path: string, visibility: FileVisibility): Promise<void>;
async getVisibility(path: string): Promise<FileVisibility>;
async files(path: string): Promise<FilesystemFile[]>;
async delete(paths: string[]): Promise<void>;
async deleteDirectory(path: string, reporter: Reporter): Promise<void>;
async exists(paths: string[]): Promise<boolean>;
async get(path: string): Promise<FilesystemFile | undefined>;
async moveFile(source: string, destination: string): Promise<void>;
async read(path: string, reporter: Reporter): Promise<Uint8Array>;
async write(path: string, contents: Uint8Array, visibility: FileVisibility, reporter: Reporter): Promise<void>;
}
Functions
(file: FilesystemModel): FilesystemFile
Types
interface FilesystemModel {
path: string;
dir: string;
type: FileType;
size: number;
created: Date;
visibility: FileVisibility;
lastModified?: Date;
}
interface FileDataModel {
path: string;
data: Uint8Array;
}
interface FilesystemOrmOptions {
database: Database;
entityClass?: ClassType<FilesystemModel>;
entityDataClass?: ClassType<FileDataModel>;
transactional?: boolean;
}