Database operations module.
- Implements:
Requires
- module:x2node-common
- module:x2node-records
- module:x2node-pointers
- module:x2node-patches
- module:x2node-validators
- module:x2node-rsparser
Classes
Mixins
Methods
-
<static> createDBOFactory(recordTypes, dbDriver [, options])
-
Create new database operations (DBO) factory using the specified database driver and the record types library. Once created, the factory instance can be used by the application throughout its life cycle.
Parameters:
Name Type Argument Description recordTypes
module:x2node-records~RecordTypesLibrary Record types library. The factory builds operations against this library. The library must be extended with the x2node-dbos
module.dbDriver
string | module:x2node-dbos.DBDriver Either a built-in database driver name, or a custom database driver implementation. Available built-in drivers include: "mysql" (for https://www.npmjs.com/package/mysql and compatible others) and "pg" (for https://www.npmjs.com/package/pg). options
Object.<string, *> <optional>
Options. If provided, the options are passed to the DB driver constructor. Throws:
-
If the provided driver name is invalid.
Returns:
DBO factory instance. -
-
<static> expr(valueExpr)
-
Get value expression placeholder object that can be used in DBO specifications.
Parameters:
Name Type Description valueExpr
string Value expression text. Returns:
Placeholder object.- Type
- Object
-
<static> isExpr(v)
-
Tell if the provided argument is a value expression placeholder.
Parameters:
Name Type Description v
* Argument to test. Safe to pass null
,undefined
, etc.Returns:
true
if the provided argument is a value expression placeholder.- Type
- boolean
-
<static> isParam(v)
-
Tell if the provided argument is a parameter placeholder.
Parameters:
Name Type Description v
* Argument to test. Safe to pass null
,undefined
, etc.Returns:
true
if the provided argument is a parameter placeholder.- Type
- boolean
-
<static> isSupported(obj)
-
Tell if the provided object is supported by the module. Currently, only a record types library instance can be tested using this function and it tells if the library was constructed with the DBOs extension.
Parameters:
Name Type Description obj
* Object to test. Returns:
true
if supported by the DBOs module.- Type
- boolean
-
<static> param(paramName)
-
Get parameter placeholder object that can be used in DBO specifications.
Parameters:
Name Type Description paramName
string Parameter name. Returns:
Placeholder object.- Type
- Object