import { IsLegalPath } from '@cbjsdev/shared'; import { CollectionOptions, ExtractCollectionJsonDocDef, ExtractCollectionJsonDocKey } from '../../../clusterTypes/clusterTypes.js'; import type { AnyCollection, MutateInArrayAddUniquePath, MutateInArrayAppendPath, MutateInArrayInsertPath, MutateInArrayPrependPath, MutateInBinaryPath, MutateInInsertPath, MutateInRemovePath, MutateInReplacePath, MutateInUpsertPath } from '../../../clusterTypes/index.js'; import { MutateInSpecResult } from '../../../clusterTypes/kv/mutation/mutateIn.types.js'; import { IllegalPathErrorMessage, MutateInArrayAddUniqueOptions, MutateInArrayAddUniqueValue, MutateInArrayAppendOptions, MutateInArrayAppendValue, MutateInArrayInsertOptions, MutateInArrayInsertValue, MutateInArrayPrependOptions, MutateInArrayPrependValue, MutateInBinaryOptions, MutateInBinaryValue, MutateInInsertOptions, MutateInInsertValue, MutateInRemoveOptions, MutateInReplaceOptions, MutateInReplaceValue, MutateInUpsertOptions, MutateInUpsertValue } from '../../../clusterTypes/kv/mutation/mutationOperations.types.js'; import { MutateInOptions } from '../../../collection.js'; import { MutateInResult } from '../../../crudoptypes.js'; import { MutateInSpec } from '../../../sdspecs.js'; type ArrayAddUniqueSpecs> = Values extends [undefined, ...infer Rest] ? [ undefined, ...ArrayAddUniqueSpecs ] : never; export declare class ChainableMutateIn, in out SpecResults extends ReadonlyArray, in out Def extends ExtractCollectionJsonDocDef = ExtractCollectionJsonDocDef> implements Promise> { protected collection: C; protected key: Key; protected options: MutateInOptions | undefined; protected specs: ReadonlyArray; [Symbol.toStringTag]: string; then, TResult2 = never>(onFulfilled?: ((value: MutateInResult) => TResult1 | PromiseLike) | undefined | null, onRejected?: ((reason: unknown) => TResult2 | PromiseLike) | undefined | null): Promise; catch(onRejected?: ((reason: unknown) => TResult | PromiseLike) | null | undefined): Promise | TResult>; finally(onFinally?: (() => void) | null | undefined): Promise>; constructor(collection: C, key: Key, options: MutateInOptions | undefined, specs: ReadonlyArray); static for>(collection: C, key: Key, options: MutateInOptions | undefined): ChainableMutateIn; push(spec: Spec): ChainableMutateIn]>; execute(): Promise>; /** * Set the value of a non-existing property. * * Fails if the field already exists at the specified path. * * @see MutateInSpec.insert * @param path The path to the field. * @param value The value to insert. * @param options Optional parameters for this operation. * @param options.createPath * Whether or not the path to the field should be created if it does not * already exist. * @param options.xattr * Whether this operation should reference the document body or the extended * attributes data for the document. */ insert, Def>, Value extends MutateInInsertValue, Def, Path>>(path: Path, value: Value, options?: MutateInInsertOptions): ChainableMutateIn; /** * Set the value of a property. If the property does not exist, it is created. * * @see MutateInSpec.upsert * @param path The path to the field. * @param value The value to write. * @param options Optional parameters for this operation. * @param options.createPath * Whether or not the path to the field should be created if it does not * already exist. * @param options.xattr * Whether this operation should reference the document body or the extended * attributes data for the document. */ upsert, Def>>(path: Path, value: MutateInUpsertValue, Def, Path>, options?: MutateInUpsertOptions): ChainableMutateIn; /** * Set the value of an existing property. * * Fails if the property does not exits. * * @see MutateInSpec.replace * @param path The path to the field. * @param value The value to write. * @param options Optional parameters for this operation. * @param options.xattr * Whether this operation should reference the document body or the extended * attributes data for the document. */ replace, Def>>(path: Path, value: MutateInReplaceValue, Def, NoInfer>, options?: MutateInReplaceOptions): ChainableMutateIn; /** * Remove a property from the document. * * Fails if the property does not exist. * * @see MutateInSpec.remove * @param path The path to the field. * @param options Optional parameters for this operation. * @param options.xattr * Whether this operation should reference the document body or the extended * attributes data for the document. */ remove, Def>>(path: Path, options?: MutateInRemoveOptions): IsLegalPath<'remove', CollectionOptions, Def['Body'], Path> extends true ? ChainableMutateIn : IllegalPathErrorMessage<'remove', Path>; /** * Add one or more values at end of an array. * * Fails if the property does not exist, unless `{ createPath: true }`. * Use the option `{ multi: true }` to add multiple values or * use `arrayAppendMultiple`. * * @see MutateInSpec.arrayAppend * @see MutateInSpec.arrayAppendMultiple * @param path The path to the field. * @param value The value to add. * @param options Optional parameters for this operation. * @param options.createPath * Whether or not the path to the field should be created if it does not * already exist. * @param options.multi * If set, this enables an array of values to be passed as value, and each * element of the passed array is added to the array. * @param options.xattr * Whether this operation should reference the document body or the extended * attributes data for the document. */ arrayAppend, Def>, Multi extends boolean = false>(path: Path, value: MutateInArrayAppendValue, Def, NoInfer, Multi>, options?: MutateInArrayAppendOptions): ChainableMutateIn; arrayAppendMultiple, Def>>(path: Path, value: MutateInArrayAppendValue, Def, NoInfer, true>, options?: Omit, 'multi'>): ChainableMutateIn; /** * Add one or more values at beginning of an array. * * Fails if the property does not exist, unless `{ createPath: true }`. * Use `{ multi: true }` to add multiple values. * * @see MutateInSpec.arrayPrepend * @param path The path to the field. * @param value The value to add. * @param options Optional parameters for this operation. * @param options.createPath * Whether or not the path to the field should be created if it does not * already exist. * @param options.multi * If set, this enables an array of values to be passed as value, and each * element of the passed array is added to the array. * @param options.xattr * Whether this operation should reference the document body or the extended * attributes data for the document. */ arrayPrepend, Def>, Multi extends boolean = false>(path: Path, value: MutateInArrayPrependValue, Def, NoInfer, Multi>, options?: MutateInArrayPrependOptions): ChainableMutateIn; arrayPrependMultiple, Def>, Value extends MutateInArrayPrependValue, Def, NoInfer, true>>(path: Path, value: NoInfer, options?: Omit, 'multi'>): ChainableMutateIn; /** * Add one or more values at a specific array index. * * Fails if the property does not exist, unless `{ createPath: true }`. * Use `{ multi: true }` to add multiple values. * * @example collection.arrayInsert('authors[1]', 'Luke'); * * @param path The path to an element of an array. * @param value The value to add. * @param options Optional parameters for this operation. * @param options.createPath * Whether or not the path to the field should be created if it does not * already exist. * @param options.multi * If set, this enables an array of values to be passed as value, and each * element of the passed array is added to the array. * @param options.xattr * Whether this operation should reference the document body or the extended * attributes data for the document. */ arrayInsert, Def>, Multi extends boolean = false>(path: Path, value: MutateInArrayInsertValue, Def, Extract, MutateInArrayInsertPath, Def>>, Multi>, options?: MutateInArrayInsertOptions): ChainableMutateIn; arrayInsertMultiple, Def>, Value extends MutateInArrayInsertValue, Def, Extract, MutateInArrayInsertPath, Def>>, true>>(path: Path, value: NoInfer, options?: Omit, 'multi'>): ChainableMutateIn; /** * Add a value to an array, but fails if the value already exists in the array. * The position of the new element is unknown. * * Fails if the property does not exist, unless `{ createPath: true }`. * * @param path The path to the field. * @param value The value to add. * @param options Optional parameters for this operation. * @param options.createPath * Whether or not the path to the field should be created if it does not * already exist. * @param options.xattr * Whether this operation should reference the document body or the extended * attributes data for the document. */ arrayAddUnique, Def>>(path: Path, value: MutateInArrayAddUniqueValue, Def, NoInfer>, options?: MutateInArrayAddUniqueOptions): ChainableMutateIn; /** * Add multiple unique values with a single spec is not natively supported. * This method emulates it by adding multiple specs, each containing a single value. * * @param path * @param values * @param options */ arrayAddUniqueMultiple, Def>, Value extends MutateInArrayAddUniqueValue, Def, NoInfer>, Values extends ReadonlyArray>(path: Path, values: NoInfer, options?: MutateInArrayAddUniqueOptions): ChainableMutateIn]>; /** * Creates a MutateInSpec for incrementing the value of a field in a document. * * @param path The path to the field. * @param incrementBy The value to add. * @param options Optional parameters for this operation. * @param options.createPath * Whether or not the path to the field should be created if it does not * already exist. * @param options.xattr * Whether this operation should reference the document body or the extended * attributes data for the document. */ increment, Def>>(path: Path, incrementBy: MutateInBinaryValue, Def, Extract, MutateInBinaryPath, Def>>>, options?: MutateInBinaryOptions): ChainableMutateIn; /** * Creates a MutateInSpec for decrementing the value of a field in a document. * * @param path The path to the field. * @param decrementBy The value to subtract. * @param options Optional parameters for this operation. * @param options.createPath * Whether or not the path to the field should be created if it does not * already exist. * @param options.xattr * Whether this operation should reference the document body or the extended * attributes data for the document. */ decrement, Def>>(path: Path, decrementBy: MutateInBinaryValue, Def, Extract, MutateInBinaryPath, Def>>>, options?: MutateInBinaryOptions): ChainableMutateIn; /** * Return the array of specs. */ getSpecs(): readonly MutateInSpec[]; } export {};