Zum Hauptinhalt springen

UpdateBuilder

UpdateBuilder

Implements​

Constructors​

Constructor​

new UpdateBuilder(table): UpdateBuilder

Creates an instance of UpdateBuilder.

Parameters​

table​

string

the name of the table

Returns​

UpdateBuilder

Member Of​

UpdateBuilder

Properties​

toString()​

toString: () => string

Generates the SQL Query

Returns​

string

  • returns a sql query

Member Of​

UpdateBuilder

Implementation of​

StatementBuilder.toString

Methods​

addColumn()​

addColumn(columns, surroundWithBrackets?): UpdateBuilder

Adds a column or a range of columns to the update statement. Important: The columns must match with the values. For optimal usage, please use the set function

Parameters​

columns​

the columns you want to update with data

string | string[]

surroundWithBrackets?​

boolean

(optional) Should surround names with brackets: column -> [column]

Returns​

UpdateBuilder

  • this instance

See​

set.

Member Of​

UpdateBuilder


addValue()​

addValue(values): UpdateBuilder

Adds a value or a range of values to the statement. Important: The values must match with the columns. For optimal usage, please use the set function

Parameters​

values​

an array with values that should be updateed

string | number | Date | (string | number | Date)[]

Returns​

UpdateBuilder

  • this instance

See​

set.

Member Of​

UpdateBuilder


set()​

set(column, value, surroundWithBrackets?): UpdateBuilder

Adds a Set condition for specified column with the new value

Parameters​

column​

string

the column you want to update

value​

the new value

string | number | Date

surroundWithBrackets?​

boolean

(optional) Should surround names with brackets: column -> [column]

Returns​

UpdateBuilder

  • this instance

Example​

const update = UpdateBuilder.table("tbl_Kunden");
update.set("Kundenname", "One Unity");
// UPDATE tbl_Kunden SET [Kundenname]='One Unity'

Member Of​

UpdateBuilder


setRange()​

setRange(range, surroundWithBrackets?): UpdateBuilder

Adds a range of Set conditions for specified column with the new value

Parameters​

range​

[string, string | number | Date][]

a range of set conditions

surroundWithBrackets?​

boolean

(optional) Should surround names with brackets: column -> [column]

Returns​

UpdateBuilder

  • this instance

Member Of​

UpdateBuilder


table()​

table(name): UpdateBuilder

Set's the table that should be updated

Parameters​

name​

string

the name of the table

Returns​

UpdateBuilder

Member Of​

UpdateBuilder


where()​

where(condition): UpdateBuilder

Adds a where condition to the query

Parameters​

condition​

string

the where condition like "[Name] like 'Huber'"

Returns​

UpdateBuilder

Example​

builder.where("[ID] = 4");

Member Of​

UpdateBuilder


setWhere()​

setWhere(range, surroundWithBrackets?): UpdateBuilder

Adds a range of where conditions

Parameters​

range​

[string, string | number | Date][]

a range of where conditions

surroundWithBrackets?​

boolean

(optional) Should surround names with brackets: column -> [column]

Returns​

UpdateBuilder

  • this instance

Member Of​

UpdateBuilder


toSQL()​

toSQL(): string

Generates the SQL Query

Returns​

string

  • returns a sql query or an empty string. Returns an empty string if count of columns and count of values doesn't match.

Member Of​

UpdateBuilder

Implementation of​

StatementBuilder.toSQL


table()​

static table(name): UpdateBuilder

Set's the table that should be updated

Parameters​

name​

string

the name of the table

Returns​

UpdateBuilder

Static​

Example​

const update = UpdateBuilder.table("tbl_Kunden");

Member Of​

UpdateBuilder