Overview
Object Compare Model
Table of contents
- CompareFunctions (type alias)
- CompareModel (type alias)
- CompareModelStruct (type alias)
- CompareObjectModelDefinition (type alias)
- PredicateOption (type alias)
- WhereCompareModel (type alias)
- WhereCompareModelT (type alias)
- WhereInputModel (type alias)
- WhereInputModel1 (type alias)
- compareModel (function)
- getCompare (function)
- getWherePropsName (function)
- parseToCompareModel (function)
- parseToWherePropName (function)
CompareFunctions (type alias)
Compare functions Struct
consist of name and function
Signature
export type CompareFunctions = {
[k: string]: Compare<any, any>
}
Added in v0.2.0
CompareModel (type alias)
Compare Model that compare WhereInputModel and Model
Signature
export type CompareModel<
W extends Record<string, any> = Record<string, any>,
T extends Record<string, any> = Record<string, any>
> = (where: WhereInputModel<W>) => PredicateOption<T>
Example
WhereInputModel:
{
name_starts_with:'刘',
age_lt: 34
}
Model
{
name:'刘兴',
age:30
}
Added in v0.2.0
CompareModelStruct (type alias)
CompareModel Group by type
Signature
export type CompareModelStruct = Record<string, CompareModel>
Added in v0.2.0
CompareObjectModelDefinition (type alias)
Define a Compare Object Model
Signature
export type CompareObjectModelDefinition = {
string: Array<string>
number: Array<string>
boolean: Array<string>
enum: Array<string>
date: Array<string>
}
Added in v0.2.0
PredicateOption (type alias)
Signature
export type PredicateOption<T> = (a: T) => O.Option<boolean>
Added in v0.2.0
WhereCompareModel (type alias)
Signature
export type WhereCompareModel<
W extends Record<string, any> = Record<string, any>,
T extends Record<string, any> = Record<string, any>
> = Compare<WhereInputModel<W>, T>
Added in v0.2.0
WhereCompareModelT (type alias)
Signature
export type WhereCompareModelT<
W extends Record<string, any> = Record<string, any>,
T extends Record<string, any> = Record<string, any>
> = Compare<WhereInputModel<W>, T>
Added in v0.2.0
WhereInputModel (type alias)
Signature
export type WhereInputModel<T> = T & {
AND?: Array<T> | T
OR?: Array<T> | T
NOT?: Array<T> | T
}
Added in v0.2.0
WhereInputModel1 (type alias)
Signature
export type WhereInputModel1<T> = T & {
AND?: Array<WhereInputModel<T>> | WhereInputModel<T>
OR?: Array<WhereInputModel<T>> | WhereInputModel<T>
NOT?: Array<WhereInputModel<T>> | WhereInputModel<T>
}
Added in v0.2.0
compareModel (function)
compare WhereInputModel and Model with CompareModel
Signature
export const compareModel =
<
W extends Record<string, any> = Record<string, any>,
T extends Record<string, any> = Record<string, any>
>
(whereT: CompareModel<W, T>[]): WhereCompareModel<W, T> => (where: WhereInputModel<W>) => ...
Added in v0.2.0
getCompare (function)
build Compare Model with CompareFunctions and prop name
Signature
export const getCompare = (as: CompareFunctions) =>
<
W extends Record<string, any> = Record<string, any>,
T extends Record<string, any> = Record<string, any>
>
(propname: string[]):
CompareModel<W, T>[] => pipe(
propname,
A.map(name =>
pipe(
R.toArray(as),
A.map(([key, value]) => ...
Added in v0.2.0
getWherePropsName (function)
Signature
export const getWherePropsName = (name: string) => (condition: string) => ...
Added in v0.2.0
parseToCompareModel (function)
Signature
export const parseToCompareModel =
<
W extends Record<string, any> = Record<string, any>,
T extends Record<string, any> = Record<string, any>
>
(modelWhere: CompareObjectModelDefinition): CompareModel<W, T>[] =>
pipe(
modelWhere,
R.mapWithIndex((key, value) => ...
Added in v0.2.0
parseToWherePropName (function)
create a where’s propery name
Signature
export const parseToWherePropName = (modelWhere: CompareObjectModelDefinition) =>
pipe(
modelWhere,
R.mapWithIndex((key, value: any) => ...
Added in v0.2.0