Class: DBQuery
@divine/uri.DBQuery
Constructors
constructor
• new DBQuery(query
, params
)
Constructs a new DBQuery object.
If one of the parameters is itself a DBQuery, the query will be merged with this one at constructon time and its parameters adopted.
This constructor is semi-private: You should use q, quote, raw, join, list, values or assign to construct queries, or just call query directly.
Throws
TypeError If one of the parameters is undefined
or if a nested DBQuery is invalid.
Parameters
Name | Type | Description |
---|---|---|
query | readonly string [] | The query segments, much like a template literal string array. |
params | unknown [] | The parameters. There should be exactly one less parameter than query segments. |
Defined in
uri/src/protocols/database.ts:395
Accessors
params
• get
params(): unknown
[]
The parameters as an array
Returns
unknown
[]
Defined in
uri/src/protocols/database.ts:431
Methods
toString
▸ toString(placeholder?
): string
Converts this query into a string.
Parameters
Name | Type | Description |
---|---|---|
placeholder | (value : unknown , index : number , query : DBQuery ) => string | A function that returns a placeholder for each parameter. Might return just ? or $1 /$2 /etc, or actually encode the parameter to make the resulting query safe for execution. |
Returns
string
The query as a string, with the parameters expanded by the placeholder
function.