dynamodb-toolbox
Version:
Lightweight and type-safe query builder for DynamoDB and TypeScript.
47 lines (46 loc) • 1.85 kB
TypeScript
import type { Condition } from '../../../entity/actions/parseCondition/index.js';
import type { EntityPathsUnion } from '../../../entity/actions/parsePaths/index.js';
import type { Entity } from '../../../entity/index.js';
import type { CapacityOption } from '../../../options/capacity.js';
import type { NoEntityMatchBehavior } from '../../../options/noEntityMatchBehavior.js';
import type { AllProjectedAttributesSelectOption, SelectOption, SpecificAttributesSelectOption } from '../../../options/select.js';
import type { IndexNames } from '../../../table/actions/indexes.js';
import type { Table } from '../../../table/index.js';
export type ScanOptions<TABLE extends Table = Table, ENTITIES extends Entity[] = Entity[]> = {
capacity?: CapacityOption;
exclusiveStartKey?: Record<string, unknown>;
limit?: number;
maxPages?: number;
filter?: Entity[] extends ENTITIES ? Condition : never;
filters?: Entity[] extends ENTITIES ? Record<string, Condition> : {
[ENTITY in ENTITIES[number] as ENTITY['entityName']]?: Condition<ENTITY>;
};
entityAttrFilter?: boolean;
noEntityMatchBehavior?: NoEntityMatchBehavior;
showEntityAttr?: boolean;
tableName?: string;
} & ({
segment?: never;
totalSegments?: never;
} | {
segment: number;
totalSegments: number;
}) & ({
consistent?: boolean;
select?: Exclude<SelectOption, AllProjectedAttributesSelectOption>;
index?: undefined;
} | {
consistent?: false;
select?: SelectOption;
index: IndexNames<TABLE, 'global'>;
} | {
consistent?: boolean;
select?: SelectOption;
index: IndexNames<TABLE, 'local'>;
}) & ({
attributes?: undefined;
select?: SelectOption;
} | {
attributes: Entity[] extends ENTITIES ? string[] : EntityPathsUnion<ENTITIES>[];
select?: SpecificAttributesSelectOption;
});