Skip to content

routier-collection


routier-collection / core/src / TupleTranslator

Class: TupleTranslator<TRoot, TShape>

Defined in: core/src/plugins/translators/TupleTranslator.ts:26

The memory half's pass over JOIN TUPLES.

JsonTranslator cannot do this job, and the reason is one line of it: map and group walk option.value.fields and deserialize each field through its PropertyInfo. A tuple has no schema and no fields — getFields over ([p, m]) => ({ ... }) extracts nothing meaningful — so that loop would either no-op or write properties onto a two-element array.

Everything a join query is allowed to do after the join is expressible as a plain closure over the tuple, and that is all this does. The lambdas the caller wrote (([p, m]) => ...) are applied as-is, which is also why the result is identical whichever backend produced the pairs.

Both halves are already in entity shape when the tuples arrive here (the wire contract), so there is nothing left to deserialize — the reason the missing field loop costs nothing.

The absent operations are absent by design, not by omission: sum/min/max/distinct and group are not declared on the tuple queryable's type, so reaching them means something built an option this API cannot express, and a throw naming it is the honest answer.

Extends

Type Parameters

TRoot

TRoot extends object

TShape

TShape

Constructors

Constructor

new TupleTranslator<TRoot, TShape>(query): TupleTranslator<TRoot, TShape>

Defined in: core/src/plugins/translators/DataTranslator.ts:27

Parameters

query

IQuery<TRoot, TShape>

Returns

TupleTranslator<TRoot, TShape>

Inherited from

DataTranslator.constructor

Methods

translate()

translate(data): ITranslatedValue<TShape>

Defined in: core/src/plugins/translators/DataTranslator.ts:75

Parameters

data

unknown

Returns

ITranslatedValue<TShape>

Inherited from

DataTranslator.translate


filter()

filter<TResult>(data, option): TResult

Defined in: core/src/plugins/translators/TupleTranslator.ts:28

Type Parameters

TResult

TResult

Parameters

data

unknown

option

QueryOption<TShape, "filter">

Returns

TResult

Overrides

DataTranslator.filter


map()

map<TResult>(data, option): TResult

Defined in: core/src/plugins/translators/TupleTranslator.ts:44

Type Parameters

TResult

TResult

Parameters

data

unknown

option

QueryOption<TShape, "map">

Returns

TResult

Overrides

DataTranslator.map


sort()

sort<TResult>(data, option): TResult

Defined in: core/src/plugins/translators/TupleTranslator.ts:51

Type Parameters

TResult

TResult

Parameters

data

unknown

option

QueryOption<TShape, "sort">

Returns

TResult

Overrides

DataTranslator.sort


skip()

skip<TResult>(data, option): TResult

Defined in: core/src/plugins/translators/TupleTranslator.ts:84

Type Parameters

TResult

TResult

Parameters

data

unknown

option

QueryOption<TShape, "skip">

Returns

TResult

Overrides

DataTranslator.skip


take()

take<TResult>(data, option): TResult

Defined in: core/src/plugins/translators/TupleTranslator.ts:93

Type Parameters

TResult

TResult

Parameters

data

unknown

option

QueryOption<TShape, "take">

Returns

TResult

Overrides

DataTranslator.take


count()

count<TResult>(data, _): TResult

Defined in: core/src/plugins/translators/TupleTranslator.ts:102

Type Parameters

TResult

TResult extends number

Parameters

data

unknown

_

QueryOption<TShape, "count">

Returns

TResult

Overrides

DataTranslator.count


join()

join(data, _): TShape

Defined in: core/src/plugins/translators/TupleTranslator.ts:115

Already joined by the time anything reaches here.

The pairs were produced either by the plugin (its translator's join) or by the datastore before this pass ran, so the option is a record of what happened rather than work to do.

Parameters

data

unknown

_

QueryOption<TShape, "join">

Returns

TShape

Overrides

DataTranslator.join


group()

group<TResult>(_, __): TResult

Defined in: core/src/plugins/translators/TupleTranslator.ts:119

Type Parameters

TResult

TResult

Parameters

_

unknown

__

QueryOption<TShape, "group">

Returns

TResult

Overrides

DataTranslator.group


sum()

sum<TResult>(_, __): TResult

Defined in: core/src/plugins/translators/TupleTranslator.ts:123

Type Parameters

TResult

TResult extends number

Parameters

_

unknown

__

QueryOption<TShape, "sum">

Returns

TResult

Overrides

DataTranslator.sum


min()

min<TResult>(_, __): TResult

Defined in: core/src/plugins/translators/TupleTranslator.ts:127

Type Parameters

TResult

TResult extends string | number | Date

Parameters

_

unknown

__

QueryOption<TShape, "min">

Returns

TResult

Overrides

DataTranslator.min


max()

max<TResult>(_, __): TResult

Defined in: core/src/plugins/translators/TupleTranslator.ts:131

Type Parameters

TResult

TResult extends string | number | Date

Parameters

_

unknown

__

QueryOption<TShape, "max">

Returns

TResult

Overrides

DataTranslator.max


distinct()

distinct<TResult>(_, __): TResult

Defined in: core/src/plugins/translators/TupleTranslator.ts:135

Type Parameters

TResult

TResult

Parameters

_

unknown

__

QueryOption<TShape, "distinct">

Returns

TResult

Overrides

DataTranslator.distinct


nearest()

nearest(_, __): TShape

Defined in: core/src/plugins/translators/TupleTranslator.ts:139

Abstract on purpose, unlike the pass-throughs a storage translator can usually inherit.

Every other shaper degrades safely when a backend ignores it — an unsorted result is still the right rows. A similarity search is not: it is the only option whose value is ENTIRELY in the ordering and the limit, so a translator that quietly passes the data through returns every row in insertion order and calls it the ten nearest.

Requiring an answer here means a new translator cannot be written without deciding whether its backend performed the search, and the compiler asks the question.

Parameters

_

unknown

__

QueryOption<TShape, "nearest">

Returns

TShape

Overrides

DataTranslator.nearest

Released under the MIT License.