Skip to content

breeze-client / TypedPredicateFactory

Interface: TypedPredicateFactory()<T> ​

Defined in: src/query/predicate.ts:59

Builds Predicates checked against one entity type - what Predicate.for returns.

Each Predicate it produces is a Predicate<T>, so combining them with and, or and not is checked too, and an EntityQuery for another type will not accept them.

Type Parameters ​

T ​

T

Call Signature ​

TypedPredicateFactory<P>(property, operator, value): Predicate<T>

Defined in: src/query/predicate.ts:69

A path only known at run time, or a query function, neither of which can be checked.

ts
const p = Predicate.for(Customer);
const byColumn = p(userChosenColumn, "eq", value);          // userChosenColumn: string
const byFunction = p("toLower(companyName)", "startsWith", "c");

Type Parameters ​

P ​

P extends string

Parameters ​

property ​

P extends `${string}(${string})` ? P : string extends P ? P : never

operator ​

string | FilterQueryOp

value ​

any

Returns ​

Predicate<T>

Call Signature ​

TypedPredicateFactory<P>(collection, quantifier, property, operator, value): Predicate<T>

Defined in: src/query/predicate.ts:71

Builds Predicates checked against one entity type - what Predicate.for returns.

Each Predicate it produces is a Predicate<T>, so combining them with and, or and not is checked too, and an EntityQuery for another type will not accept them.

Type Parameters ​

P ​

P extends string

Parameters ​

collection ​

string extends P ? P : never

quantifier ​

string | FilterQueryOp

property ​

string

operator ​

string | FilterQueryOp

value ​

any

Returns ​

Predicate<T>

Call Signature ​

TypedPredicateFactory<P, O>(property, operator, value): Predicate<T>

Defined in: src/query/predicate.ts:80

A property, an operator that suits its type, and a matching value.

ts
const p = Predicate.for(Order);
const pred = p("freight", "gt", 100);
const viaNavigation = p("customer.companyName", "startsWith", "A");

Type Parameters ​

P ​

P extends string

O ​

O extends EqualityOps | ComparisonOps | StringOps | FilterQueryOp | "in"

Parameters ​

property ​

P

operator ​

O

value ​

FilterValueFor<T, PropertyValue<T, P>, O>

Returns ​

Predicate<T>

Call Signature ​

TypedPredicateFactory<P>(collection, quantifier, predicate): Predicate<T>

Defined in: src/query/predicate.ts:88

any or all over a collection, filtered by a Predicate built for the element type.

ts
const pd = Predicate.for(OrderDetail);
const pred = Predicate.for(Order)("orderDetails", "any", pd("unitPrice", ">", 20));

Type Parameters ​

P ​

P extends string

Parameters ​

collection ​

P

quantifier ​

QuantifierOp | FilterQueryOp

predicate ​

Predicate<CollectionElement<T, P>>

Returns ​

Predicate<T>

Call Signature ​

TypedPredicateFactory<P, P2, O2>(collection, quantifier, property, operator, value): Predicate<T>

Defined in: src/query/predicate.ts:96

any or all over a collection, then a filter on the element type.

ts
const p = Predicate.for(Customer);
const pred = p("orders", "all", "freight", "lt", 100);

Type Parameters ​

P ​

P extends string

P2 ​

P2 extends string

O2 ​

O2 extends EqualityOps | ComparisonOps | StringOps | FilterQueryOp | "in"

Parameters ​

collection ​

P

quantifier ​

QuantifierOp

property ​

P2

operator ​

O2

value ​

FilterValueFor<CollectionElement<T, P>, PropertyValue<CollectionElement<T, P>, P2>, O2>

Returns ​

Predicate<T>

Call Signature ​

TypedPredicateFactory(predicate): Predicate<T>

Defined in: src/query/predicate.ts:107

The object form, checked in full.

ts
const p = Predicate.for(Customer);
const pred = p({ city: "London", companyName: { startsWith: "A" } });

Parameters ​

predicate ​

WhereObject<T>

Returns ​

Predicate<T>

Released under the MIT License.