import { type BatchWriteItemOutput, type DeleteItemInput, type DeleteItemOutput, type GetItemInput, type QueryCommandInput, type ReturnConsumedCapacity, type ScanCommandInput } from '@aws-sdk/client-dynamodb'; import { type Key } from '../interfaces/key.interface'; import type * as Metadata from '../metadata'; import { type ITable, type Table } from '../table'; import { type TableProperties } from '../tables/properties'; import { type Filters as QueryFilters, type UpdateConditions } from './filters'; import { QueryOutput } from './output'; import { MagicSearch, type MagicSearchInput } from './search'; import { type IRequestOptions } from '../connections'; type PrimaryKeyType = string | number | Date; type RangePrimaryKeyType = PrimaryKeyType | void; type PrimaryKeyBatchInput = [HashKeyType, RangeKeyType]; interface PrimaryKeyGetInput extends IRequestOptions { projectionExpression?: string; /** * Use a strongly consistent read. * Ensures you receive the most up-to-date data. * @see https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/HowItWorks.ReadConsistency.html */ consistent?: boolean; returnConsumedCapacity?: ReturnConsumedCapacity; } interface PrimaryKeyGetGetItemInput extends PrimaryKeyGetInput { key: Key; } interface PrimaryKeyQueryInput extends IRequestOptions { rangeOrder?: 'ASC' | 'DESC'; limit?: number; exclusiveStartKey?: Key; /** * Use a strongly consistent read. * Ensures you receive the most up-to-date data. * @see https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/HowItWorks.ReadConsistency.html */ consistent?: boolean; select?: 'COUNT'; } interface PrimaryKeyUpdateItem { hash: HashKeyType; range: RangeKeyType; changes: TableProperties; conditions?: UpdateConditions; } interface PrimaryKeyScanInput extends IRequestOptions { limit?: number; totalSegments?: number; segment?: number; exclusiveStartKey?: Key; attributes?: string[]; projectionExpression?: string; expressionAttributeNames?: Record; } export declare class PrimaryKey { readonly table: ITable; readonly metadata: Metadata.Index.PrimaryKey; constructor(table: ITable, metadata: Metadata.Index.PrimaryKey); getDeleteItemInput(hash: HashKeyType, range: RangeKeyType): DeleteItemInput; /** * Deletes an item from DynamoDB without having to load it from DynamoDB. * It is recommended you specify additional conditions to ensure you are deleting the record you assume. * * If you have already loaded the the record, you can use `Table.delete()`. * * Performs a `DeleteItem` operation. * @see https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_DeleteItem.html */ delete(hash: HashKeyType, range: RangeKeyType): Promise; getGetInput(input: PrimaryKeyGetGetItemInput): GetItemInput; /** * Get an item by its primary key (hash and range). * * `.get({ hashPropName: 'value', rangePropName: 'value' })` * `.get(hash, range)` * * This can be used to load the complete document, helpful if you current have a * projected version with only some attributes: * * `.get(instanceOfTable)` */ get(filters: QueryFilters, input?: PrimaryKeyGetInput): Promise; get(hash: HashKeyType, range: RangeKeyType, input?: PrimaryKeyGetInput): Promise; get(record: T, input?: PrimaryKeyGetInput): Promise; /** * Get a batch of items from this table * * This has been replaced with `Dyngoose.BatchGet` and should no longer be used. * `Dyngoose.BatchGet` has more functionality, supports projects and optionally atomic operations. * * @deprecated */ batchGet(inputs: Array>): Promise; /** * Deletes several items at once. * * WARNING: This is not atomic. * It is possible for some deletes to succeed with others fail. * Use Dyngoose.Transaction to perform an atomic deletion. * * Internally, Dyngoose will chunk the request to bypass the DynamoDB limit of 100 items per batch write. * * @see https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_BatchWriteItem.html */ batchDelete(inputs: Array>): Promise; getQueryInput(input?: PrimaryKeyQueryInput): QueryCommandInput; query(filters: QueryFilters, input?: PrimaryKeyQueryInput): Promise>; getScanInput(input?: PrimaryKeyScanInput, filters?: QueryFilters): ScanCommandInput; scan(filters?: QueryFilters | undefined | null, input?: PrimaryKeyScanInput): Promise>; /** * Query DynamoDB for what you need. * * Starts a MagicSearch using this GlobalSecondaryIndex. */ search(filters?: QueryFilters, input?: MagicSearchInput): MagicSearch; /** * Creates an instance of Table based on the key. * * Internally the record will be marked as existing, so when performing a .save() operation * it will use an UpdateItem operation which will only transmit the updated fields. * * This can lead to race conditions if not used properly. Try to use with save conditions. */ fromKey(filters: QueryFilters): T; fromKey(hash: HashKeyType, range: RangeKeyType): T; /** * This will create a temporary Table instance, then calls record.fromJSON() passing your requested changes. * record.fromJSON() handles setting and deleting attributes. * * It then has the Table.Schema build the DynamoDB.UpdateItemInput with all the requested changes. */ update(input: PrimaryKeyUpdateItem): Promise; } export {};