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
DataTranslator<TRoot,TShape>
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
Methods
translate()
translate(
data):ITranslatedValue<TShape>
Defined in: core/src/plugins/translators/DataTranslator.ts:75
Parameters
data
unknown
Returns
ITranslatedValue<TShape>
Inherited from
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
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
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
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
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
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
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
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
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
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
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
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
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