UNPKG

mantine-entity

Version:

A library combining Mantine, TanStack Query, and Mantine React Table for efficient entity management

76 lines (75 loc) 2.15 kB
export interface Collection<T = string> { /** * Horizontal filtering like selecting only certain columns */ select?: T[]; /** * Outer array represents 'and' conditions, inner array represents 'or' conditions */ where?: Where<T>[][]; /** Sets maximal number of entities to take */ t?: number; /** Sets number of entities to skip */ sk?: number; /** * Defines the ordering of the results */ orderBy?: Order[]; /** * This is a foreign key relationship (one-to-many, many-to-many, or one-to-one). * E.g., user has many roles, user has one profile, user has many permissions. * Use includes to get all related data by using the foreign key relationship. */ includes?: T[]; /** * Defines the grouping of the results */ groupBy?: T[]; /** * Outer array represents 'and' conditions, inner array represents 'or' conditions */ having?: Where<T>[][]; /** * If true, returns the total number of records that match the query, not the data. */ count?: boolean; } export interface Order<T = string> { /** * The column to order by */ column: T; /** * The direction of the ordering (ASC or DESC) */ direction?: "ASC" | "DESC"; /** * Handling of null values in the ordering */ nulls?: "nullsFirst" | "nullsLast"; } export interface Where<T = string> { /** * The column to apply the condition on */ column: T; /** * The value to compare the column against */ value: unknown; /** * The operator to use for comparison */ operator: FilterOperator; } export type FilterOperator = "=" | ">" | ">=" | "<" | "<=" | "<>" | "!=" | "LIKE" | "ILIKE" | "~" | "~*" | "IN" | "IS" | "IS DISTINCT FROM" | "@@" | "contains" | "<@" | "&&" | "&<" | "&>" | "-|-" | "NOT" | "OR" | "AND" | "ALL" | "ANY" | "IsNotNull" | "IsNull"; export interface CollectionResult<T> { /** * Total number of items matching the query */ total: number; /** * Array of items resulting from the query */ items: T[]; }