UNPKG

tiny-electron-essentials

Version:

A lightweight and modular utility library for Electron apps, offering simplified window management, tray support, IPC channels, and custom frameless window styling.

66 lines 2.85 kB
export default TinyDb; /** * A function that executes an SQL query against the database. * The query can be for fetching data (`SELECT`), modifying data (`UPDATE`, `INSERT`), * or any other valid SQL command depending on the method used. */ export type QueryRequest = (query: string, params: any[]) => any; /** * A function that executes an SQL query against the database. * The query can be for fetching data (`SELECT`), modifying data (`UPDATE`, `INSERT`), * or any other valid SQL command depending on the method used. * * @typedef {(query: string, params: any[]) => any} QueryRequest */ /** * TinyDb is an IPC-based database handler designed for Electron applications. * It connects the renderer process to a backend database using IPC events. * * This class listens to specific IPC events (`run`, `all`, `get`, `query`) identified by a unique ID, * allowing the renderer process to execute database operations securely and asynchronously. * * The class itself does not handle the database logic directly; instead, it acts as an abstract interface. * You must extend this class and override its internal methods (`#run`, `#all`, `#get`, `#query`) * to provide the actual database functionality. */ declare class TinyDb { /** * Creates a new TinyDb instance linked to a specific IPC responder and identifier. * Sets up listeners to handle database-related IPC calls (`run`, `all`, `get`, `query`). * * @param {TinyIpcResponder} ipcResponder - The IPC responder instance used for communication. * @param {string} id - A unique identifier to namespace the IPC events. */ constructor(ipcResponder: TinyIpcResponder, id: string); /** * Set the implementation for the `get` operation. * Use this for queries that fetch a single row. * * @param {QueryRequest} callback - The function to execute a `get` query. */ setGet(callback: QueryRequest): void; /** * Set the implementation for the `run` operation. * Use this for queries that modify data (`INSERT`, `UPDATE`, `DELETE`). * * @param {QueryRequest} callback - The function to execute a `run` query. */ setRun(callback: QueryRequest): void; /** * Set the implementation for the `all` operation. * Use this for queries that return multiple rows. * * @param {QueryRequest} callback - The function to execute an `all` query. */ setAll(callback: QueryRequest): void; /** * Set the implementation for the `query` operation. * Use this for any generic query, depending on the backend. * * @param {QueryRequest} callback - The function to execute a `query` operation. */ setQuery(callback: QueryRequest): void; #private; } import TinyIpcResponder from './TinyIpcResponder.mjs'; //# sourceMappingURL=TinyDb.d.mts.map