Module to convert a tdx schema into a sqlite schema.
- Source:
Methods
(static) convertRowToSqlite(schema, row) → {object.<string, (number|string)>}
Convert row of TDX values to SQLite values.
Parameters:
Name | Type | Description |
---|---|---|
schema |
object.<string, string> | Object of columns -> SQLite types |
row |
object.<string, any> | Object of a data row of column -> value |
- Source:
Returns:
- The converted values.
- Type
- object.<string, (number|string)>
(static) convertSchema(schema) → {object}
Converts a tdx schema into a sqlite schema.
Parameters:
Name | Type | Description |
---|---|---|
schema |
object | The tdx schema |
- Source:
Returns:
- The sqlite schema
- Type
- object
(static) convertToSqlite(type, value, options) → {number|string}
Converts a tdx value to a sqlite value based on a sqlite type.
Parameters:
Name | Type | Description | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
type |
string | Sqlite type to convert the value to |
||||||||
value |
string | TDX value to convert from |
||||||||
options |
object | optional addition options Properties
|
- Source:
Returns:
- The converted value.
If it is an unrecognized type it will return
null
.
- Type
- number | string
(static) convertToTdx(type, value) → {number|string|array|object}
Converts a sqlite value to a tdx value based on a sqlite type.
Parameters:
Name | Type | Description |
---|---|---|
type |
string | Sqlite type to convert the value to |
value |
string | SQlite value to convert from |
- Source:
Returns:
- The converted value.
If it is an unrecognized type it will return
null
.
- Type
- number | string | array | object
(static) escapeIdentifier(identifier) → {string}
Escapes an SQLite Identifier, e.g. a column name.
This will prevent SQLite injections, and column names being incorrectly classified as string literal values.
Mixing up the quotes can cause unexpected behaviour, since SQLite guesses whether something is a column-name or a variable.
Parameters:
Name | Type | Description |
---|---|---|
identifier |
string | The identifier to quote. |
- Source:
Returns:
The escaped and double-quoted identifier
- Type
- string
Example
// using back-ticks as JS quote character to avoid confusion
// returns `"hello""cheeseburg'er"`
converter.escapeIdentifier(`hello"cheeseburg'er`);
(static) makeNamedParameter(namedParameter) → {string}
Create a parameter for use in bind variables to SQLite statements.
This creates a 1-to-1 mapping of column name to named parameter. It escapes the chars shown in https://stackoverflow.com/a/51574648/10149169 using &hex style encoding.
Parameters:
Name | Type | Description |
---|---|---|
namedParameter |
string | The parameter to escape and make. |
- Source:
Returns:
The escaped named parameter.
- Type
- string
Example
// returns ":a((/;😀%20%29)"
makeNamedParameter("(/;😀 )");
(static) mapSchema(types) → {object}
Maps a general sqlite schema type into a valid sqlite schema.
Parameters:
Name | Type | Description |
---|---|---|
types |
object | The general sqlite schema type |
- Source:
Returns:
- The mapped valid sqlite schema
- Type
- object