@decaf-ts/db-decorators
Version:
Agnostic database decorators and repository
35 lines (34 loc) • 1.2 kB
TypeScript
import { Model } from "@decaf-ts/decorator-validation";
/**
* @summary Returns the primary key attribute for a {@link Model}
* @description searches in all the properties in the object for an {@link id} decorated property
*
* @param {Model} model
*
* @throws {InternalError} if no property or more than one properties are {@link id} decorated
* or no value is set in that property
*
* @function findPrimaryKey
*
* @category managers
*/
export declare function findPrimaryKey<M extends Model>(model: M): {
id: keyof M;
props: any;
};
/**
* @summary Returns the primary key value for a {@link Model}
* @description searches in all the properties in the object for an {@link pk} decorated property
*
* @param {Model} model
* @param {boolean} [returnEmpty]
* @return {string | number | bigint} primary key
*
* @throws {InternalError} if no property or more than one properties are {@link pk} decorated
* @throws {NotFoundError} returnEmpty is false and no value is set on the {@link pk} decorated property
*
* @function findModelID
*
* @category managers
*/
export declare function findModelId<M extends Model>(model: M, returnEmpty?: boolean): string | number | bigint;