@palmares/databases
Version:
Add support for working with databases with palmares framework
34 lines • 2.86 kB
TypeScript
import { GetQuerySet, RemoveQuerySet, SetQuerySet } from './queryset';
import type { GetDataFromModel } from './queryset';
import type { DatabaseAdapter } from '../engine';
import type { model } from '../models';
import type { FieldWithOperationType, onRemoveFunction, onSetFunction } from '../models/types';
export declare function extractDefaultEventsHandlerFromModel<TModel extends InstanceType<ReturnType<typeof model>>, TFunctionType extends 'onSet' | 'onRemove'>(modelInstance: TModel, functionType: TFunctionType): (TFunctionType extends 'onSet' ? onSetFunction<TModel> : onRemoveFunction<TModel>) | void;
/**
* What this will do is parse the search FIELD, for every field we see if it is
* of type object, if it is we parse it for the query.
*
* Parse means we send the value, the type of operation, if it's a negative and
* an object to append the result of the parse.
*
* We return either the value of the field or the object with the parsed data.
*/
export declare function parseSearchField(engine: DatabaseAdapter, key: string, fieldData: FieldWithOperationType<unknown>, inputFieldParser: (value: any) => Promise<any>, translatedModelInstance: InstanceType<ReturnType<typeof model>>, result: any): Promise<undefined | {
isValid: false;
code: string;
reason: string;
}>;
/**
* Retrieves a QuerySet instance based on the type of query you want to perform.
*
* If you are looking to perform a 'set' query, you should pass 'set' as the type.
* If you are looking to perform a 'remove' query, you should pass 'remove' as the type.
* Last but not least, if you are looking to perform a 'get' query, you should pass 'get' as the type or leave it empty.
*
* @param model The model you want to perform the query on.
* @param type The type of query you want to perform.
*
* @returns A QuerySet instance based on the type of query you want to perform.
*/
export declare function queryset<TModel, TType extends 'set' | 'remove' | 'get' = 'get'>(model: TModel, type?: TType): TType extends 'remove' ? RemoveQuerySet<'remove', TModel, GetDataFromModel<TModel, 'read'>, Partial<GetDataFromModel<TModel, 'update'>>, GetDataFromModel<TModel, 'create'>, Partial<GetDataFromModel<TModel, 'read', true>>, GetDataFromModel<TModel>, false, false, false, false, never> : TType extends 'set' ? SetQuerySet<'set', TModel, GetDataFromModel<TModel, 'read'>, Partial<GetDataFromModel<TModel, 'update'>>, GetDataFromModel<TModel, 'create'>, Partial<GetDataFromModel<TModel, 'read', true>>, GetDataFromModel<TModel>, false, false, false, false, never> : GetQuerySet<'get', TModel, GetDataFromModel<TModel, 'read'>, Partial<GetDataFromModel<TModel, 'update'>>, GetDataFromModel<TModel, 'create'>, Partial<GetDataFromModel<TModel, 'read', true>>, GetDataFromModel<TModel>, false, false, false, false, never>;
//# sourceMappingURL=utils.d.ts.map