UNPKG

tspace-mysql

Version:

Tspace MySQL is a promise-based ORM for Node.js, designed with modern TypeScript and providing type safety for schema databases.

736 lines (735 loc) 33.7 kB
import { Model } from "./Model"; import type { T } from "./UtilityTypes"; declare class RepositoryFactory<TS extends Record<string, any> = Record<string, any>, TR = unknown, M extends Model<TS, TR> = Model<TS, TR>> { private _model; constructor(_model: { new (): Model<TS, TR>; }); /** * * The 'first' method is used to retrieve the first record that matches the query conditions. * * It allows you to retrieve a single record from a database table that meets the specified criteria. * @type {?Object} options * @property {?object} options.select * @property {?object} options.except * @property {?object[]} options.orderBy * @property {?string[]} options.groupBy * @property {?string} options.having * @property {?number} options.limit * @property {?number} options.offset * @property {?object} options.where * @property {?string[]} options.whereRaw * @property {?object} options.whereQuery * @property {?{condition,callback}} options.when * @property {?{localKey , referenceKey}[]} options.join * @property {?{localKey , referenceKey}[]} options.rightJoin * @property {?{localKey , referenceKey}[]} options.leftJoin * @property {string[]} options.relations * @property {string[]} options.relationExists * @property {?{condition,callback}} options.relationQuery * @property {?boolean} options.debug * @returns {promise<Object | null>} * * @example * import { Repository } from 'tspace-mysql' * import { User } from '../Models/User' * * const userRepository = Repository(User) * * const user = await userRepository.findOne({ * select : { id: true, name: true }, * where : { * id: 1 * } * }) * * const user = await userRepository.findOne() */ first<K = {}, S extends T.SelectOptions<M> | undefined = undefined, SR extends T.RelationOptions<M> | undefined = undefined, E extends T.ExceptOptions<M> | undefined = undefined>(options?: T.RepositoryOptions<M, S, SR, E>): Promise<T.ResultFiltered<M, K, S, SR, E> | null>; /** * * The 'findOne' method is used to retrieve the findOne record that matches the query conditions. * * It allows you to retrieve a single record from a database table that meets the specified criteria. * @type {?Object} options * @property {?object} options.select * @property {?object} options.except * @property {?object[]} options.orderBy * @property {?string[]} options.groupBy * @property {?string} options.having * @property {?number} options.limit * @property {?number} options.offset * @property {?object} options.where * @property {?string[]} options.whereRaw * @property {?object} options.whereQuery * @property {?{condition,callback}} options.when * @property {?{localKey , referenceKey}[]} options.join * @property {?{localKey , referenceKey}[]} options.rightJoin * @property {?{localKey , referenceKey}[]} options.leftJoin * @property {string[]} options.relations * @property {string[]} options.relationExists * @property {?{condition,callback}} options.relationQuery * @property {?boolean} options.debug * @returns {promise<Object | null>} * * @example * import { Repository } from 'tspace-mysql' * import { User } from '../Models/User' * * const userRepository = Repository(User) * * const user = await userRepository.findOne({ * select : { id: true, name: true }, * where : { * id: 1 * } * }) * * const user = await userRepository.findOne() */ findOne<K = {}, S extends T.SelectOptions<M> | undefined = undefined, SR extends T.RelationOptions<M> | undefined = undefined, E extends T.ExceptOptions<M> | undefined = undefined>(options?: T.RepositoryOptions<M, S, SR, E>): Promise<T.ResultFiltered<M, K, S, SR, E> | null>; /** * * The 'get' method is used to retrieve the get record that matches the query conditions. * * It allows you to retrieve a single record from a database table that meets the specified criteria. * @type {?Object} options * @property {?object} options.select * @property {?object} options.except * @property {?object[]} options.orderBy * @property {?string[]} options.groupBy * @property {?string} options.having * @property {?number} options.limit * @property {?number} options.offset * @property {?object} options.where * @property {?string[]} options.whereRaw * @property {?object} options.whereQuery * @property {?{condition,callback}} options.when * @property {?{localKey , referenceKey}[]} options.join * @property {?{localKey , referenceKey}[]} options.rightJoin * @property {?{localKey , referenceKey}[]} options.leftJoin * @property {string[]} options.relations * @property {string[]} options.relationExists * @property {?{condition,callback}} options.relationQuery * @property {?boolean} options.debug * @returns {promise<Object>[]} * * @example * import { Repository } from 'tspace-mysql' * import { User } from '../Models/User' * * const userRepository = Repository(User) * * const users = await userRepository.get({ * select : { id: true, name: true }, * where : { * id: 1 * } * }) * * const users = await userRepository.get() */ get<K = {}, S extends T.SelectOptions<M> | undefined = undefined, SR extends T.RelationOptions<M> | undefined = undefined, E extends T.ExceptOptions<M> | undefined = undefined>(options?: T.RepositoryOptions<M, S, SR, E>): Promise<T.ResultFiltered<M, K, S, SR, E>[]>; /** * * The 'get' method is used to retrieve the get record that matches the query conditions. * * It allows you to retrieve a single record from a database table that meets the specified criteria. * @type {?object} options * @property {?object} options.select * @property {?object} options.except * @property {?object[]} options.orderBy * @property {?string[]} options.groupBy * @property {?string} options.having * @property {?number} options.limit * @property {?number} options.offset * @property {?object} options.where * @property {?string[]} options.whereRaw * @property {?object} options.whereQuery * @property {?{condition,callback}} options.when * @property {?{localKey , referenceKey}[]} options.join * @property {?{localKey , referenceKey}[]} options.rightJoin * @property {?{localKey , referenceKey}[]} options.leftJoin * @property {?string[]} options.relations * @property {string[]} options.relationExists * @property {?{condition,callback}} options.relationQuery * @property {?boolean} options.debug * @returns {promise<object>[]} * * @example * import { Repository } from 'tspace-mysql' * import { User } from '../Models/User' * * const userRepository = Repository(User) * * const users = await userRepository.findMany({ * select : { id: true, name: true }, * where : { * id: 1 * } * }) * * const users = await userRepository.findMany() */ findMany<K = {}, S extends T.SelectOptions<M> | undefined = undefined, SR extends T.RelationOptions<M> | undefined = undefined, E extends T.ExceptOptions<M> | undefined = undefined>(options?: T.RepositoryOptions<M, S, SR, E>): Promise<T.ResultFiltered<M, K, S, SR, E>[]>; /** * * The 'pagination' method is used to perform pagination on a set of database query results obtained through the Query Builder. * * It allows you to split a large set of query results into smaller, more manageable pages, * making it easier to display data in a web application and improve user experience. * @type {?object} options * @property {?object} options.select * @property {?object} options.except * @property {?object[]} options.orderBy * @property {?string[]} options.groupBy * @property {?string} options.having * @property {?number} options.limit * @property {?number} options.offset * @property {?object} options.where * @property {?string[]} options.whereRaw * @property {?object} options.whereQuery * @property {?{condition,callback}} options.when * @property {?{localKey , referenceKey}[]} options.join * @property {?{localKey , referenceKey}[]} options.rightJoin * @property {?{localKey , referenceKey}[]} options.leftJoin * @property {?string[]} options.relations * @property {string[]} options.relationExists * @property {?{condition,callback}} options.relationQuery * @property {?boolean} options.debug * @property {?number} options.page * @returns {promise<{ meta , data[]}>} * * @example * import { Repository } from 'tspace-mysql' * import { User } from '../Models/User' * * const userRepository = Repository(User) * * const users = await userRepository.pagination({ * select : { id: true, name: true }, * where : { * id: 1 * } * }) * * const users = await userRepository.pagination({ page : 1 , limit : 2 }) */ pagination<K = {}, S extends T.SelectOptions<M> | undefined = undefined, SR extends T.RelationOptions<M> | undefined = undefined, E extends T.ExceptOptions<M> | undefined = undefined>(options?: Partial<T.RepositoryOptions<M, S, SR, E>> & { page?: number; }): Promise<T.PaginateResultFiltered<M, K, S, SR, E>>; /** * * The 'paginate' method is used to perform pagination on a set of database query results obtained through the Query Builder. * * It allows you to split a large set of query results into smaller, more manageable pages, * making it easier to display data in a web application and improve user experience * @type {?object} options * @property {?object} options.select * @property {?object} options.except * @property {?object[]} options.orderBy * @property {?string[]} options.groupBy * @property {?string} options.having * @property {?number} options.limit * @property {?number} options.offset * @property {?object} options.where * @property {?string[]} options.whereRaw * @property {?object} options.whereQuery * @property {?{condition,callback}} options.when * @property {?{localKey , referenceKey}[]} options.join * @property {?{localKey , referenceKey}[]} options.rightJoin * @property {?{localKey , referenceKey}[]} options.leftJoin * @property {?string[]} options.relations * @property {string[]} options.relationExists * @property {?{condition,callback}} options.relationQuery * @property {?boolean} options.debug * @property {?number} options.page * @returns {promise<{ meta , data[]}>} * * @example * import { Repository } from 'tspace-mysql' * import { User } from '../Models/User' * * const userRepository = Repository(User) * * const users = await userRepository.paginate({ * select : { id: true, name: true }, * where : { * id: 1 * } * }) * * const users = await userRepository.paginate({ page : 1 , limit : 2 }) */ paginate<K = {}, S extends T.SelectOptions<M> | undefined = undefined, SR extends T.RelationOptions<M> | undefined = undefined, E extends T.ExceptOptions<M> | undefined = undefined>(options?: Partial<T.RepositoryOptions<M, S, SR, E>> & { page?: number; }): Promise<T.PaginateResultFiltered<M, K, S, SR, E>>; /** * The 'exists' method is used to determine if any records exist in the database table that match the query conditions. * * It returns a boolean value indicating whether there are any matching records. * @type {?object} options * @property {?object} options.select * @property {?object} options.except * @property {?object[]} options.orderBy * @property {?string[]} options.groupBy * @property {?string} options.having * @property {?number} options.limit * @property {?number} options.offset * @property {?object} options.where * @property {?string[]} options.whereRaw * @property {?object} options.whereQuery * @property {?{condition,callback}} options.when * @property {?{localKey , referenceKey}[]} options.join * @property {?{localKey , referenceKey}[]} options.rightJoin * @property {?{localKey , referenceKey}[]} options.leftJoin * @property {?boolean} options.debug * @property {?number} options.page */ exists(options: Partial<Omit<T.RepositoryOptions<M>, "relations" | "relationQuery">>): Promise<boolean>; /** * The 'toString' method is used to retrieve the raw SQL query that would be executed by a query builder instance without actually executing it. * * This method is particularly useful for debugging and understanding the SQL queries generated by your application. * @type {?object} options * @property {?object} options.select * @property {?object} options.except * @property {?object[]} options.orderBy * @property {?string[]} options.groupBy * @property {?string} options.having * @property {?number} options.limit * @property {?number} options.offset * @property {?object} options.where * @property {?string[]} options.whereRaw * @property {?object} options.whereQuery * @property {?{condition,callback}} options.when * @property {?{localKey , referenceKey}[]} options.join * @property {?{localKey , referenceKey}[]} options.rightJoin * @property {?{localKey , referenceKey}[]} options.leftJoin * @property {?boolean} options.debug * @property {?number} options.page * @returns {string} */ toString(options?: Partial<Omit<T.RepositoryOptions<M>, "relations" | "relationQuery">>): string; /** * The 'toJSON' method is used to execute a database query and retrieve the result set that matches the query conditions. * * It retrieves multiple records from a database table based on the criteria specified in the query. * * It returns a JSON formatted. * @type {?object} options * @property {?object} options.select * @property {?object} options.except * @property {?object[]} options.orderBy * @property {?string[]} options.groupBy * @property {?string} options.having * @property {?number} options.limit * @property {?number} options.offset * @property {?object} options.where * @property {?string[]} options.whereRaw * @property {?object} options.whereQuery * @property {?{condition,callback}} options.when * @property {?{localKey , referenceKey}[]} options.join * @property {?{localKey , referenceKey}[]} options.rightJoin * @property {?{localKey , referenceKey}[]} options.leftJoin * @property {?boolean} options.debug * @property {?number} options.page * @returns {string} json */ toJSON(options?: Partial<Omit<T.RepositoryOptions<M>, "relations" | "relationQuery">>): Promise<string>; /** * The 'toArray' method is used to execute a database query and retrieve the result set that matches the query conditions. * * It retrieves multiple records from a database table based on the criteria specified in the query. * * It returns an array formatted. * @param {string} column * @type {?object} options * @property {?object} options.select * @property {?object} options.except * @property {?object[]} options.orderBy * @property {?string[]} options.groupBy * @property {?string} options.having * @property {?number} options.limit * @property {?number} options.offset * @property {?object} options.where * @property {?string[]} options.whereRaw * @property {?object} options.whereQuery * @property {?{condition,callback}} options.when * @property {?{localKey , referenceKey}[]} options.join * @property {?{localKey , referenceKey}[]} options.rightJoin * @property {?{localKey , referenceKey}[]} options.leftJoin * @property {?boolean} options.debug * @property {?number} options.page * @return {promise<any[]>} */ toArray(column: keyof Partial<TS> | `${string}.${string}`, options?: Partial<Omit<T.RepositoryOptions<M>, "relations" | "relationQuery">>): Promise<T.Result<M>[]>; /** * The 'count' method is used to retrieve the total number of records that match the specified query conditions. * * It returns an integer representing the count of records. * @param {string} column * @type {?object} options * @property {?object} options.select * @property {?object} options.except * @property {?object[]} options.orderBy * @property {?string[]} options.groupBy * @property {?string} options.having * @property {?number} options.limit * @property {?number} options.offset * @property {?object} options.where * @property {?string[]} options.whereRaw * @property {?object} options.whereQuery * @property {?{condition,callback}} options.when * @property {?{localKey , referenceKey}[]} options.join * @property {?{localKey , referenceKey}[]} options.rightJoin * @property {?{localKey , referenceKey}[]} options.leftJoin * @property {?boolean} options.debug * @property {?number} options.page * @return {promise<any[]>} */ count(column: keyof Partial<TS> | `${string}.${string}`, options?: Partial<Omit<T.RepositoryOptions<M>, "relations" | "relationQuery">>): Promise<number>; /** * The 'avg' method is used to retrieve the total number of records that match the specified query conditions. * * It returns an integer representing the avg of records. * @param {string} column * @type {?object} options * @property {?object} options.select * @property {?object} options.except * @property {?object[]} options.orderBy * @property {?string[]} options.groupBy * @property {?string} options.having * @property {?number} options.limit * @property {?number} options.offset * @property {?object} options.where * @property {?string[]} options.whereRaw * @property {?object} options.whereQuery * @property {?{condition,callback}} options.when * @property {?{localKey , referenceKey}[]} options.join * @property {?{localKey , referenceKey}[]} options.rightJoin * @property {?{localKey , referenceKey}[]} options.leftJoin * @property {?boolean} options.debug * @property {?number} options.page * @return {promise<any[]>} */ avg(column: keyof Partial<TS> | `${string}.${string}`, options?: Partial<Omit<T.RepositoryOptions<M>, "relations" | "relationQuery">>): Promise<number>; /** * The 'sum' method is used to retrieve the total number of records that match the specified query conditions. * * It returns an integer representing the sum of records. * @param {string} column * @type {?object} options * @property {?object} options.select * @property {?object} options.except * @property {?object[]} options.orderBy * @property {?string[]} options.groupBy * @property {?string} options.having * @property {?number} options.limit * @property {?number} options.offset * @property {?object} options.where * @property {?string[]} options.whereRaw * @property {?object} options.whereQuery * @property {?{condition,callback}} options.when * @property {?{localKey , referenceKey}[]} options.join * @property {?{localKey , referenceKey}[]} options.rightJoin * @property {?{localKey , referenceKey}[]} options.leftJoin * @property {?boolean} options.debug * @property {?number} options.page * @return {promise<any[]>} */ sum(column: keyof Partial<TS> | `${string}.${string}`, options?: Partial<Omit<T.RepositoryOptions<M>, "relations" | "relationQuery">>): Promise<number>; /** * The 'max' method is used to retrieve the maximum value of a numeric column in a database table. * * It finds the highest value in the specified column among all records that match the query conditions and returns that value. * @param {string} column * @type {?object} options * @property {?object} options.select * @property {?object} options.except * @property {?object[]} options.orderBy * @property {?string[]} options.groupBy * @property {?string} options.having * @property {?number} options.limit * @property {?number} options.offset * @property {?object} options.where * @property {?string[]} options.whereRaw * @property {?object} options.whereQuery * @property {?{condition,callback}} options.when * @property {?{localKey , referenceKey}[]} options.join * @property {?{localKey , referenceKey}[]} options.rightJoin * @property {?{localKey , referenceKey}[]} options.leftJoin * @property {?boolean} options.debug * @property {?number} options.page * @return {promise<any[]>} */ max(column: keyof Partial<TS> | `${string}.${string}`, options?: Partial<Omit<T.RepositoryOptions<M>, "relations" | "relationQuery">>): Promise<number>; /** * The 'min' method is used to retrieve the minimum (lowest) value of a numeric column in a database table. * * It finds the smallest value in the specified column among all records that match the query conditions and returns that value. * @param {string} column * @type {?object} options * @property {?object} options.select * @property {?object} options.except * @property {?object[]} options.orderBy * @property {?string[]} options.groupBy * @property {?string} options.having * @property {?number} options.limit * @property {?number} options.offset * @property {?object} options.where * @property {?string[]} options.whereRaw * @property {?object} options.whereQuery * @property {?{condition,callback}} options.when * @property {?{localKey , referenceKey}[]} options.join * @property {?{localKey , referenceKey}[]} options.rightJoin * @property {?{localKey , referenceKey}[]} options.leftJoin * @property {?boolean} options.debug * @property {?number} options.page * @return {promise<any[]>} */ min(column: keyof Partial<TS> | `${string}.${string}`, options?: Partial<Omit<T.RepositoryOptions<M>, "relations" | "relationQuery">>): Promise<number>; /** * The 'create' method is used to insert a new record into a database table associated. * * It simplifies the process of creating and inserting records. * @type {object} options * @property {object} options.data * @property {?boolean} options.debug * @property {?transaction} options.transaction * @return {promise<TS>} */ create({ data, debug, transaction, }: T.RepositoryCreate<M>): Promise<T.Result<M>>; /** * The 'insert' method is used to insert a new record into a database table associated. * * It simplifies the process of creating and inserting records. * @type {object} options * @property {object} options.data * @property {?boolean} options.debug * @property {?transaction} options.transaction * @return {promise<TS>} */ insert({ data, debug }: T.RepositoryCreate<M>): Promise<T.Result<M>>; /** * The 'createNotExists' method to insert data into a database table while ignoring any duplicate key constraint violations. * * This method is particularly useful when you want to insert records into a table and ensure that duplicates are not inserted, * but without raising an error or exception if duplicates are encountered. * * @type {object} options * @property {object} options.data * @property {object} options.where * @property {?boolean} options.debug * @property {?transaction} options.transaction * @return {promise<T | null>} */ createNotExists({ data, where, debug, }: T.RepositoryCreateOrThings<M>): Promise<T.Result<M> | null>; /** * The 'insertNotExists' method to insert data into a database table while ignoring any duplicate key constraint violations. * * This method is particularly useful when you want to insert records into a table and ensure that duplicates are not inserted, * but without raising an error or exception if duplicates are encountered. * * @type {object} options * @property {object} options.data * @property {object} options.where * @property {?boolean} options.debug * @property {?transaction} options.transaction * @return {promise<T | null>} */ insertNotExists({ data, where, debug, }: T.RepositoryCreateOrThings<M>): Promise<T.Result<M> | null>; /** * The 'createMultiple' method is used to insert a new records into a database table associated. * * It simplifies the process of creating and inserting records with an array. * @type {object} options * @property {object[]} options.data * @property {?boolean} options.debug * @property {?transaction} options.transaction * @return {promise<TS[]>} */ createMultiple({ data, debug, transaction, }: T.RepositoryCreateMultiple<M>): Promise<T.Result<M>[]>; /** * The 'createMultiple' method is used to insert a new records into a database table associated. * * It simplifies the process of creating and inserting records with an array. * @type {object} options * @property {object[]} options.data * @property {?boolean} options.debug * @property {?transaction} options.transaction * @return {promise<TS[]>} */ insertMultiple({ data, debug, }: T.RepositoryCreateMultiple<M>): Promise<T.Result<M>[]>; /** * * The 'createOrUpdate' method allows you to update an existing record in a database table if it exists or create a new record if it does not exist. * * This method is particularly useful when you want to update a record based on certain conditions and, * if the record matching those conditions doesn't exist, create a new one with the provided data. * @type {object} options * @property {object} options.data * @property {object} options.where * @property {?boolean} options.debug * @return {promise<TS>} */ createOrUpdate({ data, where, debug, }: T.RepositoryCreateOrThings<M>): Promise<T.Result<M>>; /** * * The 'insertOrUpdate' method allows you to update an existing record in a database table if it exists or create a new record if it does not exist. * * This method is particularly useful when you want to update a record based on certain conditions and, * if the record matching those conditions doesn't exist, create a new one with the provided data. * @type {object} options * @property {object} options.data * @property {object} options.where * @property {?boolean} options.debug * @return {promise<TS>} */ insertOrUpdate({ data, where, debug, }: T.RepositoryCreateOrThings<M>): Promise<T.Result<M>>; /** * * The 'createOrSelect' method to insert data into a database table while select any duplicate key constraint violations. * * This method is particularly useful when you want to insert records into a table and ensure that duplicates are not inserted, * but if exists should be returns a result. * @type {object} options * @property {object} options.data * @property {object} options.where * @property {?boolean} options.debug * @return {promise<TS>} */ createOrSelect({ data, where, debug, }: T.RepositoryCreateOrThings<M>): Promise<T.Result<M>>; /** * * The 'insertOrSelect' method to insert data into a database table while select any duplicate key constraint violations. * * This method is particularly useful when you want to insert records into a table and ensure that duplicates are not inserted, * but if exists should be returns a result. * @type {object} options * @property {object} options.data * @property {object} options.where * @property {?boolean} options.debug * @property {?transaction} options.transaction * @return {promise<TS>} */ insertOrSelect({ data, where, debug, }: T.RepositoryCreateOrThings<M>): Promise<T.Result<M>>; /** * The 'update' method is used to update existing records in a database table that are associated. * * It simplifies the process of updating records by allowing you to specify the values to be updated using a single call. * * It allows you to remove one record that match certain criteria. * @type {object} options * @property {object} options.data * @property {object} options.where * @property {?boolean} options.debug * @property {?transaction} options.transaction * @return {promise<TS>} */ update({ data, where, debug, transaction, }: T.RepositoryUpdate<M>): Promise<T.Result<M>>; /** * The 'updateMany' method is used to update existing records in a database table that are associated. * * It simplifies the process of updating records by allowing you to specify the values to be updated using a single call. * * It allows you to remove more records that match certain criteria. * @type {object} options * @property {object} options.data * @property {object} options.where * @property {?boolean} options.debug * @property {?transaction} options.transaction * @return {promise<TS>} */ updateMany({ data, where, debug, transaction, }: T.RepositoryUpdate<M>): Promise<T.Result<M>[]>; /** * The 'updateCases' method is used to update records in a table based on specific conditions. * * This method allows updating multiple rows at once by specifying an array of update cases. * Each case defines which records to update (`when`) and the new values to apply (`columns`). * * @type {object} options * @property {object} options.data * @property {object} options.where * @property {?boolean} options.debug * @property {?transaction} options.transaction * @return {promise<TS[]>} * @example * const saveUpdateMultiple = await userRepository.updateCases({ * cases : [ * { * when : { * id: 1 * }, * columns : { * name : 'name-edit-in-multiple : id 1 ' * } * }, * { * when : { * id : 2 * }, * columns : { * name : 'name-edit-in-multiple : id 2' * } * } * ], * where : { * id : Operator.in([1,2]) * } * }) * */ updateCases({ cases, debug, transaction, }: T.RepositoryUpdateMultiple<M>): Promise<T.Result<M>[]>; /** * The 'delete' method is used to delete records from a database table based on the specified query conditions. * * It allows you to remove one record that match certain criteria. * @type {object} options * @property {object} options.data * @property {object} options.where * @property {?boolean} options.debug * @property {?transaction} options.transaction * @return {promise<boolean>} */ delete({ where, debug, transaction, }: T.RepositoryDelete<M>): Promise<boolean>; /** * The 'deleteMany' method is used to delete records from a database table based on the specified query conditions. * * It allows you to remove one record that match certain criteria. * @type {object} options * @property {object} options.data * @property {object} options.where * @property {?boolean} options.debug * @property {?transaction} options.transaction * @return {promise<boolean>} */ deleteMany({ where, debug, transaction, }: T.RepositoryDelete<M>): Promise<boolean>; private _handleRelationQuery; private _handlerRequest; } /** * * The 'Repository' is a class that encapsulates all database operations related to a specific model. * * It provides methods for querying, inserting, updating, and deleting records in the database associated with the model. * * * * The 'bind' method is used to bind the model to the repository * @param {Model} model A class constructor for a model * @returns {RepositoryFactory<T,R>} * * @example * import { Repository } from 'tspace-mysql' * import { User } from '../Models/User' * * const userRepository = Repository(User) * * const user = await userRepository.findOne() * const users = await userRepository.findMany() * */ export declare const Repository: <M extends Model<any, any>>(model: new () => M) => RepositoryFactory<T.SchemaModel<M>, T.RelationModel<M>, M>; export default Repository;