import type { IdbqlIndexedCore } from "../idbqlCore/idbqlCore.js"; interface IdbqlIndexedCore { [key: string]: CollectionCore; } import type { CollectionCore } from "../collection/collection.svelte.js"; import { type Where, type ResultSet, type ResultsetOptions } from "@medyll/idae-query"; /** * Main entry point. * Creates a state object with indexedDB synchronization. * @param {IdbqlIndexedCore} [idbBase] - The IdbqlCore instance. * @returns {object} - The state object. */ export declare const createIdbqlState: (idbBase: IdbqlIndexedCore, options?: { adapter?: "svelte" | "stator"; adapterOptions?: any; }) => { collectionState: Record>; qolie: (collection: string) => { put: (value: Partial) => Promise; get: any; getBy: (value: any, pathKey?: string) => ResultSet; getOne: any; getAll: () => ResultSet; create: (value: Partial) => Promise; delete: (keyPathValue: string | number) => Promise; deleteWhere: (where: Where) => Promise; update: (keyPathValue: string | number, data: Partial) => Promise; where: (qy: Where, options?: ResultsetOptions) => ResultSet; updateWhere: (where: Where, data: Partial) => Promise; count: (qy?: Where | undefined) => Promise; }; }; /** * Represents a dynamic state collection that interacts with an IndexedDB base. * Provides methods for performing CRUD operations and querying the collection. * * @template T - The type of items in the collection. */ export declare class CollectionState { private collectionName; private idbBase; /** * Creates an instance of StateCollectionDyn. * @param {string} collectionName - The name of the collection. * @param {IdbqlIndexedCore} idbBase - The instance of the IndexedDB base. */ constructor(collectionName: string, idbBase: IdbqlIndexedCore); /** * Gets the current state of the collection. * @returns {ResultSet} The state of the collection. */ get collectionState(): ResultSet; /** * Tests if the collection exists in the IndexedDB base. * @param {string} collection - The name of the collection. * @returns {boolean} True if the collection exists, otherwise false. */ private testIdbql; /** * Feeds the collection with data from the IndexedDB base. */ private feed; /** * Performs a "where" query on the collection. * @param {Where} qy - The "where" query. * @param {ResultsetOptions} [options] - Optional result set options. * @returns {ResultSet} The result set of the query. */ _where(qy: Where, options?: ResultsetOptions): ResultSet; /** * Gets a function to perform a "where" query on the collection. * @returns {(qy: Where, options?: ResultsetOptions) => ResultSet} The function to perform the query. */ get where(): (qy: Where, options?: ResultsetOptions) => ResultSet; /** * Gets items from the collection by a specific value and key. * @param {any} value - The value to search for. * @param {string} [pathKey="id"] - The key to search by. * @returns {T | undefined} The item found, or undefined if not found. */ get get(): T | undefined; /** * Gets items from the collection by a specific value and key using a "where" query. * @param {any} value - The value to search for. * @param {string} [pathKey="id"] - The key to search by. * @returns {ResultSet} The result set of the query. */ getBy(value: any, pathKey?: string): ResultSet; /** * Gets a single item from the collection by a specific value and key. * @deprecated Use getBy instead. * @param {any} value - The value to search for. * @param {string} [pathKey="id"] - The key to search by. * @returns {T | undefined} The item found, or undefined if not found. */ get getOne(): T | undefined; /** * Gets all items from the collection. * @returns {ResultSet} The result set of all items. */ getAll: () => ResultSet; /** * Updates an item in the collection by a specific key path value. * @param {string | number} keyPathValue - The key path value of the item to update. * @param {Partial} data - The data to update. * @returns {Promise} True if the update was successful, otherwise undefined. */ update(keyPathValue: string | number, data: Partial): Promise; /** * Updates items in the collection that match a "where" query. * @param {Where} where - The "where" query to match items. * @param {Partial} data - The data to update. * @returns {Promise} True if the update was successful, otherwise undefined. */ updateWhere(where: Where, data: Partial): Promise; /** * Puts an item into the collection. * @param {Partial} value - The item to put. * @returns {Promise} The item put, or undefined if the operation failed. */ put(value: Partial): Promise; /** * Adds an item to the collection. * @param {T} data - The item to add. * @returns {Promise} The item added, or undefined if the operation failed. */ add(data: T): Promise; /** * Deletes an item from the collection by a specific key path value. * @param {string | number} keyPathValue - The key path value of the item to delete. * @returns {Promise} True if the deletion was successful, otherwise undefined. */ delete(keyPathValue: string | number): Promise; /** * Deletes an item from the collection by a specific key path value. * @deprecated Use delete instead. * @param {string | number} keyPathValue - The key path value of the item to delete. * @returns {Promise} True if the deletion was successful, otherwise undefined. */ del(keyPathValue: string | number): Promise; /** * Deletes items from the collection that match a "where" query. * @param {Where} where - The "where" query to match items. * @returns {Promise} True if the deletion was successful, otherwise undefined. */ deleteWhere(where: Where): Promise; /** * Counts the number of documents in the collection. * When called without a query parameter, it uses the native IndexedDB count() method for optimal performance. * When called with a query parameter, it retrieves all matching documents to return the count. * * @param {Where} [qy] - Optional query object specifying the conditions for filtering the data. * @returns {Promise} A promise that resolves to the number of documents matching the query (or all documents if no query is provided). * * @example * // Count all documents in the collection (fast, uses native count) * const totalCount = await collectionState.count(); * * @example * // Count documents matching a query (retrieves matching documents) * const activeCount = await collectionState.count({ status: 'active' }); * * @example * // Count with complex query * const count = await collectionState.count({ age: { $gt: 18 }, status: 'active' }); */ count(qy?: Where): Promise; } export {};