@wxn0brp/db
Version:
A simple file-based database management system with support for CRUD operations, custom queries, and graph structures.
52 lines (51 loc) • 2.47 kB
TypeScript
import { Search, Updater } from "./arg.js";
import Data from "./data.js";
import { FindOpts } from "./options.js";
import { Context } from "./types.js";
interface FileCpu {
/**
* Asynchronously adds an entry to a file.
* @param file The path to the file.
* @param data The data to add.
* @returns A promise resolving to `void`.
*/
add(file: string, data: Data): Promise<void>;
/**
* Asynchronously finds multiple entries in a file based on search criteria.
* @param file The path to the file.
* @param arg The search criteria.
* @param context Additional context for the search.
* @param findOpts Additional options for searching.
* @returns A promise resolving to an array of found entries, or `false` if the file does not exist.
*/
find(file: string, arg: Search, context?: Context, findOpts?: FindOpts): Promise<any[] | false>;
/**
* Asynchronously finds one entry in a file based on search criteria.
* @param file The path to the file.
* @param arg The search criteria.
* @param context Additional context for the search.
* @param findOpts Additional options for searching.
* @returns A promise resolving to the found entry or `false` if not found.
*/
findOne(file: string, arg: Search, context?: Context, findOpts?: FindOpts): Promise<any | false>;
/**
* Asynchronously removes entries from a file based on search criteria.
* @param file The path to the file.
* @param arg The search criteria.
* @param context Additional context for the operation.
* @param one If `true`, removes only the first matching entry.
* @returns A promise resolving to `true` if at least one entry was removed, otherwise `false`.
*/
remove(file: string, one: boolean, arg: Search, context?: Context): Promise<boolean>;
/**
* Asynchronously updates entries in a file based on search criteria and an updater function or object.
* @param file The path to the file.
* @param arg The search criteria.
* @param updater The updater function or object.
* @param context Additional context for the operation.
* @param one If `true`, updates only the first matching entry.
* @returns A promise resolving to `true` if at least one entry was updated, otherwise `false`.
*/
update(file: string, one: boolean, arg: Search, updater: Updater, context?: Context): Promise<boolean>;
}
export default FileCpu;