collectype

collectype v0.11.0


collectype / factory/bigints/bigIntRange / bigIntRangeFactory

Function: bigIntRangeFactory()

bigIntRangeFactory<T, C>(ctx, oper): <K>(field, min, max) => C

Defined in: factory/bigints/bigIntRange.ts:40

Creates a predicate filter for bigint range using PredicType.bigint.range.

Type Parameters

T

T

The item type in the collection.

C

C extends Wherable<T, C>

The Wherable context type (must extend Wherable<T, C>).

Parameters

ctx

C

The context (usually a collection) supporting the where method.

oper

BigIntRangeOper

The bigint range operation (e.g., ‘between’, ‘notBetween’, etc.).

Returns

Returns a function that takes a field (of type bigint on T), a min and max value, and applies the bigint range predicate to filter the context.

<K>(field, min, max): C

Type Parameters

K

K extends string | number | symbol

Parameters

field

K

min

bigint

max

bigint

Returns

C

Example

// Example: Composing a bigint range filter as a property, homogeneous model
import { BaseFunctions } from 'collectype';
import { bigIntRangeFactory } from 'collectype';

type Person = { name: string; balance: bigint };

class PersonFunctions extends BaseFunctions<Person> {
  bigIntBetween = bigIntRangeFactory<Person, this>(this, 'between');
}

// Usage:
const people: Person[] = [
  { name: 'Alice', balance: 1000n },
  { name: 'Bob', balance: 2000n }
];
const fn = new PersonFunctions(people);
const filtered = fn.bigIntBetween('balance', 500n, 1500n);
// filtered contains the items where 'balance' is between 500n and 1500n

Remarks