harperdb
Version:
HarperDB is a distributed database, caching service, streaming broker, and application development platform focused on performance and ease of use.
95 lines (94 loc) • 3.19 kB
TypeScript
import { makeTable } from './Table.ts';
export declare const NON_REPLICATING_SYSTEM_TABLES: string[];
export type Table = ReturnType<typeof makeTable>;
export interface Tables {
[tableName: string]: Table;
}
export interface Databases {
[databaseName: string]: Tables;
}
export declare const tables: Tables;
export declare const databases: Databases;
export declare const databaseEnvs: Map<string, any>;
/**
* This gets the set of tables from the default database ("data").
*/
export declare function getTables(): Tables;
/**
* This provides the main entry point for getting the set of all HarperDB tables (organized by schemas/databases).
* This proactively scans the known
* databases/schemas directories and finds any databases and opens them. This done proactively so that there is a fast
* object available to all consumers that doesn't require runtime checks for database open states.
* This also attaches the audit store associated with table. Note that legacy tables had a single audit table per db table
* but in newer multi-table databases, there is one consistent, integrated audit table for the database since transactions
* can span any tables in the database.
*/
export declare function getDatabases(): Databases;
export declare function resetDatabases(): Databases;
/**
* This is responsible for reading the internal dbi of a single database file to get a list of all the tables and
* their indexed or registered attributes
* @param path
* @param defaultTable
* @param databaseName
*/
export declare function readMetaDb(path: string, defaultTable?: string, databaseName?: string, auditPath?: string, isLegacy?: boolean): any;
interface TableDefinition {
table: string;
database?: string;
path?: string;
expiration?: number;
eviction?: number;
scanInterval?: number;
audit?: boolean;
sealed?: boolean;
splitSegments?: boolean;
replicate?: boolean;
trackDeletes?: boolean;
attributes: any[];
schemaDefined?: boolean;
origin?: string;
}
/**
* Get root store for a database
* @param options
* @returns
*/
export declare function database({ database: databaseName, table: tableName }: {
database: any;
table: any;
}): any;
/**
* Delete the database
* @param databaseName
*/
export declare function dropDatabase(databaseName: any): Promise<void>;
/**
* This can be called to ensure that the specified table exists and if it does not exist, it should be created.
* @param tableName
* @param databaseName
* @param customPath
* @param expiration
* @param eviction
* @param scanInterval
* @param attributes
* @param audit
* @param sealed
* @param splitSegments
* @param replicate
*/
export declare function table<TableResourceType>(tableDefinition: TableDefinition): TableResourceType;
export declare function dropTableMeta({ table: tableName, database: databaseName }: {
table: any;
database: any;
}): Promise<any[]>;
export declare function onUpdatedTable(listener: any): {
remove(): void;
};
export declare function onRemovedDB(listener: any): {
remove(): void;
};
export declare function getDefaultCompression(): {
startingOffset: number;
};
export {};