Skip to main content
Module

x/cotton/mod.ts>QueryBuilder

SQL Database Toolkit for Deno
Go to Latest
class QueryBuilder
import { QueryBuilder } from "https://deno.land/x/cotton@v0.2.0/mod.ts";

Constructors

new
QueryBuilder(tableName: string, adapter?: BaseAdapter)

Properties

private
columns: string[]

Table columns that are going to be fetched

private
orders: OrderBinding[]

The orderings for the query.

private
optional
queryLimit: number

The maximum number of records to return

private
optional
queryOffset: number

The number of records to skip

private
wheres: WhereBinding[]

The where constraints of the query

Methods

private
addWhereClause(
fieldName: string,
operator: WhereOperators,
value: any,
)

Add new where clause to query

execute(): Promise<any[]>

Get the first record of the query, shortcut for limit(1)

limit(limit: number): QueryBuilder

Set the "limit" value for the query.

offset(offset: number): QueryBuilder

Set the "offset" value for the query.

select(...fields: string[]): QueryBuilder
toSQL(): string

Generate executable SQL query string

where(fieldName: string, value: any): QueryBuilder

Add basic where clause to query

where(
fieldName: string,
operator: WhereOperators,
value: any,
): QueryBuilder