UNPKG

@decaf-ts/for-couchdb

Version:
40 lines (39 loc) 2.53 kB
import { MaybeContextualArg, Repository } from "@decaf-ts/core"; import { Model } from "@decaf-ts/decorator-validation"; import { Constructor } from "@decaf-ts/decoration"; import type { CouchDBAdapter } from "./adapter.d.mts"; import { ContextOf } from "@decaf-ts/core"; import type { PrimaryKeyType } from "@decaf-ts/db-decorators"; export declare class CouchDBRepository<M extends Model, A extends CouchDBAdapter<any, any, any>> extends Repository<M, A> { constructor(adapter: A, model: Constructor<M>, force?: boolean); protected assignMetadata(model: M, source?: M): M; protected assignMetadata(models: M[], source?: M[]): M[]; create(model: M, ...args: MaybeContextualArg<ContextOf<A>>): Promise<M>; createAll(models: M[], ...args: MaybeContextualArg<ContextOf<A>>): Promise<M[]>; read(id: PrimaryKeyType, ...args: MaybeContextualArg<ContextOf<A>>): Promise<M>; readAll(ids: PrimaryKeyType[], ...args: MaybeContextualArg<ContextOf<A>>): Promise<M[]>; update(model: M, ...args: MaybeContextualArg<ContextOf<A>>): Promise<M>; updateAll(models: M[], ...args: MaybeContextualArg<ContextOf<A>>): Promise<M[]>; delete(id: PrimaryKeyType, ...args: MaybeContextualArg<ContextOf<A>>): Promise<M>; deleteAll(ids: PrimaryKeyType[], ...args: MaybeContextualArg<ContextOf<A>>): Promise<M[]>; /** * @description Prepares a model for update. * @summary Validates the model and prepares it for update in the database. * @param {M} model - The model to update. * @param {...any[]} args - Additional arguments. * @return The prepared model and context arguments. * @throws {InternalError} If the model has no primary key value. * @throws {ValidationError} If the model fails validation. */ protected updatePrefix(model: M, ...args: MaybeContextualArg<ContextOf<A>>): Promise<[M, ...args: any[], ContextOf<A>, M | undefined]>; /** * @description Prepares multiple models for update. * @summary Validates multiple models and prepares them for update in the database. * @param {M[]} models - The models to update. * @param {...any[]} args - Additional arguments. * @return {Promise<any[]>} The prepared models and context arguments. * @throws {InternalError} If any model has no primary key value. * @throws {ValidationError} If any model fails validation. */ protected updateAllPrefix(models: M[], ...args: MaybeContextualArg<ContextOf<A>>): Promise<[M[], ...args: any[], ContextOf<A>, M[] | undefined]>; }