Skip to content

Overview

The CommonGrants.Filters namespace contains a series of basic filters that can be used to define both standard and custom filtering within

Filters

Learn more about the default filters supported by the CommonGrants protocol:

Base filter and operators

FilterDescription
EquivalenceOperatorsOperators that filter a field based on an exact match
ComparisonOperatorsOperators that filter a field based on a comparison
ArrayOperatorsOperators that filter a field based on an array
StringOperatorsOperators that filter a field based on a string
RangeOperatorsOperators that filter a field based on a range
AllOperatorsCombined set of all filter operators

String

FilterDescription
StringComparisonFilterFilters by comparing a field to a string value
StringArrayFilterFilters by comparing a field to an array of strings

Numeric

FilterDescription
NumberComparisonFilterFilters by comparing a field to a numeric value
NumberRangeFilterFilters by comparing a field to a range of numeric values
NumberArrayFilterFilters by comparing a field to an array of numeric values

Money

FilterDescription
MoneyComparisonFilterFilters by comparing a field to a monetary value
MoneyRangeFilterFilters by comparing a field to a range of monetary values

Date and time

FilterDescription
DateComparisonFilterFilters by comparing a field to a date value
DateRangeFilterFilters by comparing a field to a range of date values
isoTimeTime without timezone in ISO 8601 format (HH:mm:ss)
isoDateCalendar date in ISO 8601 format (YYYY-MM-DD)
utcDateTimeDatetime with UTC timezone in ISO 8601 format (YYYY-MM-DDThh:mm:ssZ)
offsetDateTimeDatetime with timezone in ISO 8601 format (YYYY-MM-DDThh:mm:ss±hh:mm)

Other types

FilterDescription
booleanA true or false value
arrayAn ordered list of values
recordA collection of key-value pairs
nullA null value
unknownA value of with any type

Usage

You can use the types listed above to define custom models in your TypeSpec project.

import "@common-grants/core"
// Exposes the `Types` namespace so that it can be accessed
// without a `CommonGrants` prefix
using CommonGrants;
model MyModel {
id: Types.uuid; // CommonGrants-defined type
description: string; // Standard TypeSpec type
tags: Array<string>; // A templated type
createdAt: utcDateTime;
}