import SimpleWebDB from "./SimpleWebDB.js"; import SimpleTable from "./SimpleTable.js"; /** * SimpleDB is a class that provides a simplified interface for working with DuckDB, a high-performance, in-memory analytical database. This class is meant to be used with NodeJS and similar runtimes. For web browsers, use SimpleWebDB. * * With very expensive computations, it might create a .tmp folder, so make sure to add .tmp to your gitignore. * * Here's how to instantiate a SimpleDB instance and then a SimpleTable. * * @example * Basic usage * ```ts * // Instantiating the database. * const sdb = new SimpleDB() * * // Creating a new table. * const employees = sdb.newTable("employees") * * // You can now invoke methods on the table. * await employees.loadData("./employees.csv") * await employees.logTable() * * // To free up memory. * await sdb.done() * ``` * * @example * Instanciating with options * ```ts * // Creating a database with options. Debug information will be logged each time a method is invoked. The first 20 rows of tables will be logged (default is 10). * const sdb = new SimpleWebDB({ debug: true, nbRowsToLog: 20 }) * ``` * * @param options - Configuration options for the SimpleDB instance. * @param options.logDuration - Whether to log the duration of operations. * @param options.nbRowsToLog - Number of rows to log when displaying table data. * @param options.nbCharactersToLog - Number of characters to log when displaying text content. Useful for long strings. * @param options.cacheVerbose - Whether to log cache-related messages. * @param options.debug - Whether to enable debug logging. * @param options.bigIntToInt - Whether to convert BigInt values to integers. Defaults to true. */ export default class SimpleDB extends SimpleWebDB { /** A flag to log messages relative to the cache. Defaults to false. */ cacheVerbose: boolean; /** Amount of time saved by using the cache. */ cacheTimeSaved: number; constructor(options?: { logDuration?: boolean; nbRowsToLog?: number; nbCharactersToLog?: number; cacheVerbose?: boolean; debug?: boolean; bigIntToInt?: boolean; }); /** * Initializes DuckDB and establishes a connection to the database. For internal use only. * * @category Internal */ start(): Promise; /** Creates a table in the DB. * * @example * Basic usage * ```ts * // This returns a new SimpleTable * const employees = sdb.newTable() * ``` * * @example * With a specific name * ```ts * // By default, tables will be named table1, table2, etc. * // But you can also give them specific names. * const employees = sdb.newTable("employees") * ``` * * @param name - The name of the new table. * @param projections - The projections of the geospatial data, if any. * * @category DB methods */ newTable(name?: string, projections?: { [key: string]: string; }): SimpleTable; /** * Frees up memory by closing down the database and cleans up cache so it doesn't grow in size indefinitely. * * @example * Basic usage * ```typescript * await sdb.done(); * ``` * * @category DB methods */ done(): Promise; }