Abstract
Protected
convertPerforms a database delete and returns the number of deleted records.
Sql delete statement
Optional
aParameterValues: UFDynamicObjectValues to use in case the statement contains parameters
number of deleted records.
Protected
Abstract
fieldExecute a sql to get a single value.
Sql statement to perform
Optional
aParameterValues: UFDynamicObjectValues to use in case the statement contains parameters
Optional
aDefault: anyDefault value to return if the sql statement did not have any results
result from sql statement or aDefault
Execute a sql to get a single value as a certain type.
Sql statement to perform
Values to use in case the statement contains parameters
Default value to return if the sql statement did not have any results
result from sql statement or aDefault
Execute a sql to get a single value as a certain type. If no value can be found, the method will throw an error.
Sql statement to perform
Optional
aParameterValues: UFDynamicObjectValues to use in case the statement contains parameters
result from sql statement
if no row (and thus field) can be found
Generates a unique code with UFText.generateCode to be used in some table.
Table to use unique code with
Name of column in table that contains the unique code
Number of characters the code should exist of
an unique code
Abstract
insertPerforms an insert and returns the id of the created record.
Sql insert statement
Optional
aParameterValues: UFDynamicObjectValues to use in case the statement contains parameters
id of created record or 0 if there is no id.
Inserts a data from an object. The method creates an insert into statement using the property names inside the object.
The aData structure can contain a primary key property, when building the sql statement it will be skipped. After the insert statement the generated id (if any) will be assigned to the primary key field.
Name of table
Data to insert (should be some form of object)
Name of primary key field
Fields to ignore in aData
Either aData if there is no primary key or a new object with values copied from aData with the new primary key value.
Protected
processProcesses a sql with named parameters and replaces the named parameters with values returned by the callback.
Sql statement to process.
An object that contains properties whose name match the named parameters
This callback is invoked for every found named parameter. The result will be used to replace the named parameter.
an updated SQL statement
Protected
Abstract
rowExecute a sql to get a row.
Sql statement to perform
Optional
aParameterValues: UFDynamicObjectValues to use in case the statement contains parameters
result from sql statement; undefined when no row could be found
Execute a sql to get a row as a certain type.
Sql statement to perform
Optional
aParameterValues: UFDynamicObjectValues to use in case the statement contains parameters
result from sql statement; undefined when no row could be found
Execute a sql to get a row as a certain type. If no row can be found, the method will throw an error.
Sql statement to perform
Optional
aParameterValues: UFDynamicObjectValues to use in case the statement contains parameters
result from sql statement
error if no row can be found
Protected
Abstract
rowsExecute a sql to get multiple rows.
Sql statement to perform
Optional
aParameterValues: UFDynamicObjectValues to use in case the statement contains parameters
Result from sql statement
Execute a sql to get multiple rows as a certain type.
Sql statement to perform
Optional
aParameterValues: UFDynamicObjectValues to use in case the statement contains parameters
result from sql statement
Abstract
transactionExecute a function within a transaction.
A function that will be called with await. It will be called with a single parameter, which can be used to communicate with the database. The parameter might be a different instance then the instance the transaction call originated from.
any exception that occurred while calling aCallback
Abstract
updatePerforms an update and returns the number of changed records.
Sql update statement
Optional
aParameterValues: UFDynamicObjectValues to use in case the statement contains parameters
number of changed records.
Updates a record in a table assuming it has a single primary key column.
Name of table
Primary key vale
Object containing field names and their new values.
Name of primary key
Fields to ignore in aData
UFDatabase can act as a base class for database implementations.
It supports named parameters in sql queries, using ':name' where name can be a combination of letters, numbers and underscores.
The parameter values are contained in a dynamic object, where the property names match the named parameter.
Subclasses can use processSqlParameters to convert the sql statement.
The class defines several abstract methods subclasses must implement.