Metakit / @doeixd/metakit

Eq

namespace · packages/metakit/src/ops/eq.ts:13

export * as Eq from './ops/eq.js'

Equality and set-membership primitive operators: eq.is and eq.in, and SQL's = and in (eq.equals, eq.among); isNot is not(is(…)).

eq.is and eq.in are null-safe: null equals null and nothing else, so these never give null; eq.equals and eq.among give null as SQL does. Every equality refuses text holding a NUL (unportable) and NaN (non-finite) in any operand or candidate before null decides, as the orders do. Uses Effect Equal.equals (with Object.is and ±0 normalization). SQL lowering emits IS NOT DISTINCT FROM / IS on nullable columns so JS and SQL never diverge.

In the guides

Members

Eq.among

function · packages/metakit/src/ops/eq.ts:133

function among<
  X extends ExprInput<never, unknown>,
  const C extends ReadonlyArray<NoInfer<Exclude<ValueOfInput<X>, null>> | null>,
>(
  value: X,
  candidates: C,
): Expr<
  EnvOfInput<X>,
  boolean | NullOf<X> | (null extends C[number] ? null : never)
>

Membership as SQL's in answers it: false among no candidate, null for a null value among some, and null where nothing matches and a candidate is null. Text holding a NUL and NaN are refused. Eq.oneOf never gives null.

Eq.amongOp

const · packages/metakit/src/ops/eq.ts:69

const amongOp = { id, returns, nulls, evaluate }

SQL's in. In order: a refused operand refuses; a null list gives null; no candidate gives false, whatever the value, null included (SQLite's x in (), and what Drizzle writes for an empty inArray); text holding a NUL or NaN, in the value or a candidate, refuses; a null value gives null; then true for a match, null where none matches beside a null candidate, and false.

Eq.equals

function · packages/metakit/src/ops/eq.ts:119

function equals<
  L extends ExprInput<never, unknown>,
  R extends ExprInput<never, NoInfer<ValueOfInput<L>> | null>,
>(
  left: L,
  right: R,
): Expr<EnvOfInput<L> & EnvOfInput<R>, boolean | NullOf<L> | NullOf<R>>

Equality as SQL's = answers it: null where either side is null, so a rule over a missing value does not hold; NaN and text holding a NUL are refused. Eq.is is the equality where null equals null.

Eq.equalsOp

const · packages/metakit/src/ops/eq.ts:54

const equalsOp = { id, returns, nulls, refuses, evaluate }

SQL's =: refused for text holding a NUL or for NaN, on either side and before null; then null where either side is null.

Eq.in

function · packages/metakit/src/ops/eq.ts:143

function in<X extends ExprInput<never, unknown>>(value: X, candidates: ReadonlyArray<NoInfer<ValueOfInput<X>>>): Expr<EnvOfInput<X>, boolean>;

True when value equals one of the literal candidates.

Eq.inOp

const · packages/metakit/src/ops/eq.ts:35

const inOp = { id, returns, nulls, evaluate }

Eq.inSet

function · packages/metakit/src/ops/eq.ts:143

function inSet<X extends ExprInput<never, unknown>>(
  value: X,
  candidates: ReadonlyArray<NoInfer<ValueOfInput<X>>>,
): Expr<EnvOfInput<X>, boolean>

True when value equals one of the literal candidates.

Eq.is

function · packages/metakit/src/ops/eq.ts:97

function is<
  L extends ExprInput<never, unknown>,
  R extends ExprInput<never, NoInfer<ValueOfInput<L>> | null>,
>(left: L, right: R): Expr<EnvOfInput<L> & EnvOfInput<R>, boolean>

Equality between two values of the same type; null equals only null. The right operand is constrained by the left operand's type so literal unions get autocomplete and typos (e.g. Eq.is(row.status, 'typo')) fail to compile.

Eq.isNot

function · packages/metakit/src/ops/eq.ts:106

function isNot<
  L extends ExprInput<never, unknown>,
  R extends ExprInput<never, NoInfer<ValueOfInput<L>> | null>,
>(left: L, right: R): Expr<EnvOfInput<L> & EnvOfInput<R>, boolean>

Inequality between two values of the same type: Bool.not(Eq.is(left, right)), so null-safe too.

Eq.isOp

const · packages/metakit/src/ops/eq.ts:25

const isOp = { id, returns, nulls, evaluate }

Eq.oneOf

function · packages/metakit/src/ops/eq.ts:143

function oneOf<X extends ExprInput<never, unknown>>(
  value: X,
  candidates: ReadonlyArray<NoInfer<ValueOfInput<X>>>,
): Expr<EnvOfInput<X>, boolean>

True when value equals one of the literal candidates.