select-statement overview
Represents https://www.sqlite.org/syntax/simple-select-stmt.html
Added in v2.0.0
Table of contents
utils
AliasedSelectStatement (class)
Signature
export declare class AliasedSelectStatement<Selection, Alias, Scope, FlatScope>
Added in v2.0.0
commaJoin (property)
Signature
commaJoin: <
Selection2 extends string = never,
Alias2 extends string = never,
Scope2 extends ScopeShape = never,
FlatScope2 extends string = never
>(
_: ValidAliasInSelection<
Joinable<Selection2, Alias2, Scope2, FlatScope2>,
Alias2
>
) =>
Joined<
never,
never,
{ [key in Alias]: Selection } & { [key in Alias2]: Selection2 },
Selection | Selection2
>;
Added in v2.0.0
join (property)
Signature
join: <
Selection2 extends string = never,
Alias2 extends string = never,
Scope2 extends ScopeShape = never,
FlatScope2 extends string = never
>(
operator: string,
_: ValidAliasInSelection<
Joinable<Selection2, Alias2, Scope2, FlatScope2>,
Alias2
>
) =>
JoinedFactory<
{ [key in Alias]: Selection } & { [key in Alias2]: Selection2 },
Extract<Selection, Selection2>
>;
Added in v2.0.0
apply (property)
Signature
apply: <Ret extends TableOrSubquery<any, any, any, any> = never>(
fn: (it: this) => Ret
) => Ret;
Added in v2.0.0
stringify (property)
Signature
stringify: () => string;
Added in v2.0.0
select (property)
Signature
select: <
NewSelection extends string = never,
SubSelection extends Selection = never
>(
_:
| readonly SubSelection[]
| ((
fields: Record<Selection, SafeString> &
SelectionOfScope<{ [key in Alias]: Selection }> &
NoSelectFieldsCompileError
) => Record<NewSelection, SafeString>)
) =>
SelectStatement<
NewSelection | SubSelection,
never,
{ [key in Alias]: Selection },
Selection
>;
Added in v2.0.0
selectStar (property)
Signature
selectStar: () =>
SelectStatement<Selection, never, { [key in Alias]: Selection }, Selection>;
Added in v2.0.0
appendSelectStar (property)
Signature
appendSelectStar: () =>
AliasedSelectStatement<
Selection,
Alias,
Scope & { [key in Alias]: Selection },
Selection
>;
Added in v2.0.0
as (property)
Signature
as: <NewAlias extends string = never>(as: NewAlias) =>
AliasedSelectStatement<Selection, NewAlias, Scope, FlatScope>;
Added in v2.0.0
SelectStatement (class)
Represents https://www.sqlite.org/syntax/simple-select-stmt.html
This class is not meant to be used directly, but rather through the fromNothing
function or from a table.
Signature
export declare class SelectStatement<Selection, Alias, Scope, FlatScope> {
protected constructor(
/**
* @internal
*/
public __props: {
readonly from: TableOrSubquery<any, any, any, any> | null;
readonly selection: SelectionWrapperTypes;
readonly replace: ReplaceT<Selection>;
readonly orderBy: ReadonlyArray<SafeString>;
readonly groupBy: ReadonlyArray<SafeString>;
readonly limit: SafeString | number | null;
readonly where: ReadonlyArray<SafeString>;
readonly prewhere: ReadonlyArray<SafeString>;
readonly except: ReadonlyArray<SafeString>;
readonly having: ReadonlyArray<SafeString>;
readonly distinct: boolean;
readonly clickhouseWith: ReadonlyArray<ClickhouseWith>;
readonly ctes: ReadonlyArray<CTE>;
readonly alias?: string;
readonly scope: ScopeStorage;
readonly rollup: boolean;
}
);
}
Added in v2.0.0
clickhouse (property)
Clickhouse specific syntax extensions.
Signature
clickhouse: {
with_: <NewSelection extends string>(
it: Record<
NewSelection,
| SafeString
| SelectStatement<any, any, any, any>
| AliasedSelectStatement<any, any, any, any>
| StringifiedSelectStatement<any, any, any, any>
| AliasedStringifiedSelectStatement<any, any, any, any>
>
) => SelectStatement<Selection | NewSelection, Alias, Scope, FlatScope | NewSelection>
prewhere: (
f:
| readonly (Selection | FlatScope)[]
| ((fields: Record<Selection | FlatScope, SafeString>) => ReadonlyArray<SafeString> | SafeString)
) => SelectStatement<Selection, Alias, Scope, FlatScope>
except: (
f:
| readonly (Selection | FlatScope)[]
| ((fields: Record<Selection | FlatScope, SafeString>) => ReadonlyArray<SafeString> | SafeString)
) => SelectStatement<Selection, Alias, Scope, FlatScope>
replace: (
_: (
f: Record<Selection | FlatScope, SafeString> & SelectionOfScope<Scope> & NoSelectFieldsCompileError
) => ReplaceT<Selection>
) => SelectStatement<Selection, Alias, Scope, FlatScope>
withRollup: () => SelectStatement<Selection, Alias, Scope, FlatScope>
}
Added in v2.0.0
select (property)
Signature
select: <
NewSelection extends string = never,
SubSelection extends Selection = never
>(
_:
| readonly SubSelection[]
| ((
fields: RecordOfSelection<Selection> & NoSelectFieldsCompileError
) => Record<NewSelection, SafeString>)
) =>
SelectStatement<
NewSelection | SubSelection,
never,
Record<string, never>,
Selection
>;
Added in v2.0.0
selectStar (property)
Signature
selectStar: () =>
SelectStatement<Selection, never, { [key in Alias]: Selection }, Selection>;
Added in v2.0.0
appendSelectStar (property)
Signature
appendSelectStar: () => SelectStatement<Selection, Alias, Scope, Selection>;
Added in v2.0.0
appendSelect (property)
Signature
appendSelect: <NewSelection extends string = never>(
_:
| readonly Selection[]
| ((
fields: RecordOfSelection<Selection> &
RecordOfSelection<FlatScope> &
SelectionOfScope<Scope> &
NoSelectFieldsCompileError
) => Record<NewSelection, SafeString>)
) => SelectStatement<Selection | NewSelection, Alias, Scope, FlatScope>;
Added in v2.0.0
where (property)
Signature
where: (
f:
| readonly (Selection | FlatScope)[]
| ((
fields: Record<Selection | FlatScope, SafeString> &
SelectionOfScope<Scope>
) => ReadonlyArray<SafeString> | SafeString)
) => SelectStatement<Selection, Alias, Scope, FlatScope>;
Added in v2.0.0
having (property)
Signature
having: (
f:
| readonly (Selection | FlatScope)[]
| ((
fields: Record<Selection | FlatScope, SafeString>
) => ReadonlyArray<SafeString> | SafeString)
) => SelectStatement<Selection, Alias, Scope, FlatScope>;
Added in v2.0.0
distinct (property)
Signature
distinct: () => SelectStatement<Selection, Alias, Scope, FlatScope>;
Added in v2.0.0
orderBy (property)
Signature
orderBy: (
f:
| readonly (Selection | FlatScope)[]
| ((
fields: Record<Selection | FlatScope, SafeString> &
SelectionOfScope<Scope>
) => ReadonlyArray<SafeString> | SafeString)
) => SelectStatement<Selection, Alias, Scope, FlatScope>;
Added in v2.0.0
groupBy (property)
Signature
groupBy: (
f:
| readonly (Selection | FlatScope)[]
| ((
fields: Record<Selection | FlatScope, SafeString>
) => ReadonlyArray<SafeString> | SafeString)
) => SelectStatement<Selection, Alias, Scope, FlatScope>;
Added in v2.0.0
limit (property)
Signature
limit: (limit: SafeString | number) =>
SelectStatement<Selection, Alias, Scope, FlatScope>;
Added in v2.0.0
apply (property)
Signature
apply: <Ret extends TableOrSubquery<any, any, any, any> = never>(
fn: (it: this) => Ret
) => Ret;
Added in v2.0.0
stringify (property)
Signature
stringify: () => string;
Added in v2.0.0
as (property)
Signature
as: <NewAlias extends string = never>(as: NewAlias) =>
AliasedSelectStatement<Selection, NewAlias, Scope, FlatScope>;
Added in v2.0.0