@mantlebee/ts-data
    Preparing search index...

    Type Alias InMemoryQueryItemsReaderOptions<TItem>

    Options of the in-memory delegates (filterItems, sortItems) and of queryItems / countItems: how the values of the items and of the filters are compared.

    type InMemoryQueryItemsReaderOptions<TItem = Any> = {
        caseSensitive?: boolean;
        nullSemantics?: InMemoryNullSemantics;
        toComparable?: InMemoryQueryItemsComparer<TItem>;
    }

    Type Parameters

    • TItem = Any

      Type of the items.

    Index
    caseSensitive?: boolean

    true to compare strings as they are. By default (false) strings are lower-cased before any comparison, so equal, contains, startsWith, endsWith, in and the sorts ignore the case. equalInsensitive ignores the case whatever this option.

    nullSemantics?: InMemoryNullSemantics

    How the filters match an unset field, see InMemoryNullSemantics. "javascript" by default; "sql" makes an in-memory fake agree with a SQL backend, where status <> 'archived' drops the rows whose status is NULL.

    const items = [{ status: "active" }, { status: null }];
    const notArchived: FiltersExpression<Item> = {
    filters: [{ field: "status", operator: FilterOperators.notEqual, value: "archived" }],
    logic: FilterLogics.and,
    };
    filterItems(items, notArchived); // both items
    filterItems(items, notArchived, { nullSemantics: "sql" }); // [{ status: "active" }]

    Replaces the default conversion (toComparableValue) of a value into the primitive actually compared. It receives both sides of every comparison, the value of the item and the value of the filter, with the field they belong to, so the rule can differ per field. Its result is used as it is: lower-case the strings yourself when needed. Return null for an unset value.

    // Prices are value objects compared by their amount in cents.
    const options: InMemoryQueryItemsReaderOptions<Product> = {
    toComparable: (value, field) =>
    field === "price" ? (value as Price).cents : toComparableValue(value),
    };