import { type QueryCommandInput, type ScanCommandInput } from '@aws-sdk/client-dynamodb'; import { type Key } from '../interfaces/key.interface'; import { type ITable, type Table } from '../table'; import { Condition } from './condition'; import { type AttributeNames, type Filters } from './filters'; import { type GlobalSecondaryIndex } from './global-secondary-index'; import { type LocalSecondaryIndex } from './local-secondary-index'; import { QueryOutput } from './output'; import { type PrimaryKey } from './primary-key'; type Index = PrimaryKey | GlobalSecondaryIndex | LocalSecondaryIndex | string; export interface MagicSearchInput { limit?: number; exclusiveStartKey?: Key; attributes?: string[]; projectionExpression?: string; rangeOrder?: 'ASC' | 'DESC'; consistent?: boolean; returnOnlyCount?: boolean; /** * Perform your query on the specified index, which can be a GSI object or a string */ index?: Index; } export type SearchGroupFunction = (condition: MagicSearch) => any; /** * Use this via Table.search() */ export declare class MagicSearch { private readonly tableClass; private readonly input; private filters; constructor(tableClass: ITable, filters?: Filters, input?: MagicSearchInput); addFilterGroup(filters: Array>): this; parenthesis(value: SearchGroupFunction): this; group(value: SearchGroupFunction): this; filter>(a1: K1): Condition>; filter>, K2 extends keyof NonNullable>(a1: K1, a2: K2): Condition[K2]>>; filter, K2 extends keyof NonNullable, K3 extends keyof NonNullable[K2]>>(a1: K1, a2: K2, a3: K3): Condition[K2]>[K3]>>; filter, K2 extends keyof NonNullable, K3 extends keyof NonNullable[K2]>, K4 extends keyof NonNullable[K2]>[K3]>>(a1: K1, a2: K2, a3: K3, a4: K4): Condition[K2]>[K3]>[K4]>>; where>(a1: K1): Condition>; where>, K2 extends keyof NonNullable>(a1: K1, a2: K2): Condition[K2]>>; where, K2 extends keyof NonNullable, K3 extends keyof NonNullable[K2]>>(a1: K1, a2: K2, a3: K3): Condition[K2]>[K3]>>; where, K2 extends keyof NonNullable, K3 extends keyof NonNullable[K2]>, K4 extends keyof NonNullable[K2]>[K3]>>(a1: K1, a2: K2, a3: K3, a4: K4): Condition[K2]>[K3]>[K4]>>; or(): this; and(): this; /** * This function will limit the number of documents that DynamoDB will process in this query request. * * Unlike most SQL databases this does not guarantee the response will contain 5 documents. * Instead DynamoDB will only query a maximum of 5 documents to see if they match and should be returned. * The limit parameter passed in should be a number representing how many documents you wish DynamoDB to process. */ limit(limit: number): this; /** * When there are more documents available to your query than DynamoDB can return, * Dyngoose will let you know by specifying Results.lastEvaluatedKey. * * You can pass that object into this method to get additional results from your table. */ startAt(exclusiveStartKey?: Key): this; /** * This function will limit which attributes DynamoDB returns for each item in the table * by building a ProjectionExpression for you. * * This can limit the size of the DynamoDB response and helps you only retrieve the data you need. * Simply provide an array of strings representing the property names you wish DynamoDB to return. */ properties>(...propertyNames: Attr[]): this; /** * This is similar to `.properties()` except it accepts a list of attribute names * instead of property names. */ attributes(...attributeNames: string[]): this; /** * Instead of returning the records, this function will cause the query operation to return only the count of possible results. */ count(): this; /** * This will cause the query to run in a consistent manner as opposed to the default eventually consistent manner. */ consistent(consistent?: boolean): this; /** * This causes the query to be run on a specific index as opposed to the default table wide query. * The index parameter you pass in should represent the name of the index you wish to query on. */ using(index: Index | null): this; /** * This function sorts the documents you receive back by the rangeKey. By default, if not provided, it will sort in ascending order. * * The order parameter must be a string either equal to ascending or descending. */ sort(direction: 'ascending' | 'descending'): this; ascending(): this; descending(): this; /** * This will execute the query you constructed and return one page of results. * * A promise will be returned that will resolve to the results array upon completion. */ exec(): Promise>; /** * This will execute the query you constructed and page, if necessary, until the * minimum number of requested documents is loaded. * * This can be useful if you are doing advanced queries without good indexing, * which should be avoided but can happen for infrequent operations such as analytics. * * Unlike `.all()` which pages until all results are loaded, `.minimum(min)` will * page only until the specified number of records is loaded and then halts. * * It is recommended you apply a `.limit(minOrMore)` before calling `.minimum` to ensure * you do not load too many results as well. */ minimum(minimum: number): Promise>; /** * Page internally and return all possible search results. * * Be cautious. This can easily cause timeouts if you're using Lambda functions. * This is also non-ideal for scans, for better performance use a segmented scan * via the Query.PrimaryKey.segmentedScan or Query.GlobalSecondaryIndex.segmentedScan. */ all(): Promise>; getInput(): ScanCommandInput | QueryCommandInput; /** * @deprecated Use MagicSearch.prototype.exec() */ search(): Promise>; page(input: ScanCommandInput | QueryCommandInput): Promise>; private findAvailableIndex; private checkFilters; } export {};