Skip to main content
Using Deno in production at your company? Earn free Deno merch.
Give us feedback
Module

x/cotton/src/querycompiler.ts>QueryCompiler

SQL Database Toolkit for Deno
Latest
class QueryCompiler
import { QueryCompiler } from "https://deno.land/x/cotton@v0.7.5/src/querycompiler.ts";

Transform QueryDescription to an executable SQL query string

Constructors

new
QueryCompiler(description: QueryDescription, dialect: DatabaseDialect)

Properties

private
values: DatabaseValues[]

Methods

private
bindValue(value: DatabaseValues | DatabaseValues[]): string

Transform value to a format that the database can understand

private
collectConstraints(): string[]

Collect query constraints in the current query

Example result:

["WHERE `users`.`email` = ?", "AND `users`.`age` > 16", "LIMIT 1"]
private
getColumnName(column: string | string[]): string
private
getWhereBindings(keyword: "WHERE" | "HAVING", bindings: WhereBinding[]): string

Compile where bindings from query description to a string.

Example result:

WHERE `users`.`email` = ? AND `users`.`age` >= ?
private
normalizeColumnName(column: string)
private
toDeleteSQL(): string

Generate DELETE query string

private
toInsertSQL(replace?: boolean): string

Generate INSERT query string

private
toSelectSQL(): string

Generate SELECT query string

private
toUpdateSQL(): string

Generate UPDATE query string

compile(): { text: string; values: any[]; }

Generate executable SQL statement