@decaf-ts/for-postgres
Version:
template for ts projects
37 lines (36 loc) • 2.02 kB
TypeScript
import { Constructor, Model } from "@decaf-ts/decorator-validation";
import { Repository } from "@decaf-ts/core";
import { Context } from "@decaf-ts/db-decorators";
import { PostgresAdapter } from "./adapter";
import { PostgresFlags, PostgresQuery } from "./types";
/**
* @description Type for PostgreSQL database repositories
* @summary A specialized repository type for working with PostgreSQL databases, extending the base Repository
* with PostgreSQL-specific adapter, flags, and context types
* @template M - Type extending Model that this repository will manage
* @memberOf module:for-postgres
*/
export declare class PostgresRepository<M extends Model> extends Repository<M, PostgresQuery, PostgresAdapter, PostgresFlags, Context<PostgresFlags>> {
constructor(adapter: PostgresAdapter, model: Constructor<M>, ...args: any[]);
/**
* @description Reads a model from the database by ID.
* @summary Retrieves a model instance from the database using its primary key.
* @param {string|number|bigint} id - The primary key of the model to read.
* @param {...any[]} args - Additional arguments.
* @return {Promise<M>} The retrieved model instance.
*/
read(id: string | number | bigint, ...args: any[]): Promise<M>;
/**
* @description Deletes a model from the database by ID.
* @summary Removes a model instance from the database using its primary key.
* @param {string|number|bigint} id - The primary key of the model to delete.
* @param {...any[]} args - Additional arguments.
* @return {Promise<M>} The deleted model instance.
*/
delete(id: string | number | bigint, ...args: any[]): Promise<M>;
protected createAllPrefix(models: M[], ...args: any[]): Promise<any[]>;
createAll(models: M[], ...args: any[]): Promise<M[]>;
readAll(keys: string[] | number[], ...args: any[]): Promise<M[]>;
updateAll(models: M[], ...args: any[]): Promise<M[]>;
deleteAll(keys: string[] | number[], ...args: any[]): Promise<M[]>;
}