> ## Documentation Index
> Fetch the complete documentation index at: https://docs.bijection.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Class: RelationalQuery<Plan>

> A declarative relation.

[server](/api/modules/server).RelationalQuery

A declarative relation. Construct this with q.table, never with a database callback.

## Type parameters

| Name |
| :- |
| `Plan` |

## Constructors

### constructor

• **new RelationalQuery**\<`Plan`>(`plan`)

#### Type parameters

| Name |
| :- |
| `Plan` |

#### Parameters

| Name | Type |
| :- | :- |
| `plan` | [`ViewPlan`](/api/modules/server#viewplan) |

## Properties

### planType

• `Readonly` **planType**: `Plan`

***

### plan

• `Readonly` **plan**: [`ViewPlan`](/api/modules/server#viewplan)

## Methods

### as

▸ **as**\<`Name`>(`alias`): [`RelationalQuery`](/api/classes/server.RelationalQuery)\<`Alias`\<`Plan`, `Name`>>

#### Type parameters

| Name | Type |
| :- | :- |
| `Name` | extends `string` |

#### Parameters

| Name | Type |
| :- | :- |
| `alias` | `Name` |

#### Returns

[`RelationalQuery`](/api/classes/server.RelationalQuery)\<`Alias`\<`Plan`, `Name`>>

***

### filter

▸ **filter**\<`Predicate`>(`predicate`): [`RelationalQuery`](/api/classes/server.RelationalQuery)\<`Filter`\<`Plan`, `Predicate`>>

#### Type parameters

| Name | Type |
| :- | :- |
| `Predicate` | extends [`Expression`](/api/classes/server.Expression)\<`boolean`, `Predicate`> |

#### Parameters

| Name | Type |
| :- | :- |
| `predicate` | `Predicate` |

#### Returns

[`RelationalQuery`](/api/classes/server.RelationalQuery)\<`Filter`\<`Plan`, `Predicate`>>

***

### select

▸ **select**\<`Fields`>(`fields`): [`RelationalQuery`](/api/classes/server.RelationalQuery)\<`Select`\<`Plan`, `Fields`>>

#### Type parameters

| Name | Type |
| :- | :- |
| `Fields` | extends `Selection` |

#### Parameters

| Name | Type |
| :- | :- |
| `fields` | `Fields` |

#### Returns

[`RelationalQuery`](/api/classes/server.RelationalQuery)\<`Select`\<`Plan`, `Fields`>>

***

### leftJoin

▸ **leftJoin**\<`Right`, `Options`>(`right`, `options`): [`RelationalQuery`](/api/classes/server.RelationalQuery)\<`Join`\<`Plan`, `Right`, `"left"`, `Options`>>

#### Type parameters

| Name | Type |
| :- | :- |
| `Right` | `Right` |
| `Options` | extends [`ViewJoinOptions`](/api/modules/server#viewjoinoptions) |

#### Parameters

| Name | Type |
| :- | :- |
| `right` | [`RelationalQuery`](/api/classes/server.RelationalQuery)\<`Right`> |
| `options` | `Options` |

#### Returns

[`RelationalQuery`](/api/classes/server.RelationalQuery)\<`Join`\<`Plan`, `Right`, `"left"`, `Options`>>

***

### innerJoin

▸ **innerJoin**\<`Right`, `Options`>(`right`, `options`): [`RelationalQuery`](/api/classes/server.RelationalQuery)\<`Join`\<`Plan`, `Right`, `"inner"`, `Options`>>

#### Type parameters

| Name | Type |
| :- | :- |
| `Right` | `Right` |
| `Options` | extends [`ViewJoinOptions`](/api/modules/server#viewjoinoptions) |

#### Parameters

| Name | Type |
| :- | :- |
| `right` | [`RelationalQuery`](/api/classes/server.RelationalQuery)\<`Right`> |
| `options` | `Options` |

#### Returns

[`RelationalQuery`](/api/classes/server.RelationalQuery)\<`Join`\<`Plan`, `Right`, `"inner"`, `Options`>>

***

### groupBy

▸ **groupBy**\<`Fields`>(`fields`, `window?`): `Object`

#### Type parameters

| Name | Type |
| :- | :- |
| `Fields` | extends readonly `string`\[] |

#### Parameters

| Name | Type |
| :- | :- |
| `fields` | `Fields` |
| `window?` | [`ViewWindow`](/api/modules/server#viewwindow) |

#### Returns

`Object`

| Name | Type |
| :- | :- |
| `aggregate` | \<Aggregates>(`aggregates`: `Aggregates`) => [`RelationalQuery`](/api/classes/server.RelationalQuery)\<`Group`\<`Plan`, `Fields`, `Aggregates`>> |


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.