import type { QueryNode } from '../operation-node/query-node.js'; import type { NoResultErrorConstructor } from '../query-builder/no-result-error.js'; import type { AbortableQueryOptions } from './abort.js'; import type { SimplifyResult, SimplifySingleResult } from './type-utils.js'; export interface Executable { /** * Executes the query and returns an array of rows. * * Also see the {@link executeTakeFirst} and {@link executeTakeFirstOrThrow} methods. */ execute(options?: AbortableQueryOptions): Promise[]>; /** * Executes the query and returns the first result or undefined if * the query returned no result. */ executeTakeFirst(options?: AbortableQueryOptions): Promise>; /** * Executes the query and returns the first result or throws if * the query returned no result. * * By default an instance of {@link NoResultError} is thrown, but you can * provide a custom error class, or callback to throw a different * error. */ executeTakeFirstOrThrow(options?: ExecuteTakeFirstOrThrowOptions | ExecuteTakeFirstOrThrowOptions['errorConstructor']): Promise>; } export interface ExecuteTakeFirstOrThrowOptions extends AbortableQueryOptions { /** * An optional error constructor that is used to create an error * when the query returns no results. * * By default, an instance of {@link NoResultError} is thrown. */ errorConstructor?: NoResultErrorConstructor | ((node: QueryNode) => Error); }