new TableName(table, schemaopt) → {helpers.TableName}
Alternative Syntax: TableName({table, [schema]})
⇒ helpers.TableName
Prepares and escapes a full table name that can be injected into queries directly.
This is a read-only type that can be used wherever parameter table
is supported.
It supports Custom Type Formatting, which means you can use the type directly as a formatting parameter, without specifying any escaping.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
table |
string | object | Table name details, depending on the type:
|
|
schema |
string |
<optional> |
Database schema name. When |
Properties:
Name | Type | Description |
---|---|---|
name |
string | Formatted/escaped full table name, based on properties |
table |
string | Table name. |
schema |
string | Database schema name. It is |
- Source:
Returns:
- Type
- helpers.TableName
Example
const table = new pgp.helpers.TableName('my-table', 'my-schema');
console.log(table);
//=> "my-schema"."my-table"
// Formatting the type directly:
pgp.as.format('SELECT * FROM $1', table);
//=> SELECT * FROM "my-schema"."my-table"
Methods
toString() → {string}
Creates a well-formatted string that represents the object.
It is called automatically when writing the object into the console.
- Source:
Returns:
- Type
- string