@decaf-ts/db-decorators
Version:
Agnostic database decorators and repository
35 lines (34 loc) • 1.15 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<T extends Model>(model: T): {
id: string;
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} 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(model: Model, returnEmpty?: boolean): any;