pg-promise 11.7.3 → 11.7.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -140,7 +140,7 @@ npm.utils.addInspection(TableName, function () {
|
|
|
140
140
|
* @function helpers._TN
|
|
141
141
|
* @description
|
|
142
142
|
* Table-Name helper function, to convert any `"schema.table"` string
|
|
143
|
-
* into `{schema, table}` object.
|
|
143
|
+
* into `{schema, table}` object. It also works as a template-tag function.
|
|
144
144
|
*
|
|
145
145
|
* @example
|
|
146
146
|
* const {ColumnSet, _TN} = pgp.helpers;
|
|
@@ -149,14 +149,15 @@ npm.utils.addInspection(TableName, function () {
|
|
|
149
149
|
* const cs1 = new ColumnSet(['id', 'name'], {table: _TN('schema.table')});
|
|
150
150
|
*
|
|
151
151
|
* // Using as a template-tag function:
|
|
152
|
-
* const
|
|
152
|
+
* const schema = 'schema';
|
|
153
|
+
* const cs2 = new ColumnSet(['id', 'name'], {table: _TN`${schema}.table`});
|
|
153
154
|
*
|
|
154
155
|
* @returns {Table}
|
|
155
156
|
*/
|
|
156
157
|
function _TN(a, ...args) {
|
|
157
158
|
if (Array.isArray(a) && a.raw) {
|
|
158
|
-
a =
|
|
159
|
-
}
|
|
159
|
+
a = a.map((b, i) => b + (i < args.length ? args[i] : '')).join('');
|
|
160
|
+
} // else 'a' is a string
|
|
160
161
|
const [schema, table] = a.split('.');
|
|
161
162
|
return table === undefined ? {table: schema} : {schema, table};
|
|
162
163
|
}
|
package/package.json
CHANGED
|
@@ -708,7 +708,8 @@ declare namespace pgPromise {
|
|
|
708
708
|
ColumnSet: typeof ColumnSet
|
|
709
709
|
TableName: typeof TableName
|
|
710
710
|
|
|
711
|
-
_TN
|
|
711
|
+
_TN(data: TemplateStringsArray, ...args: Array<any>): ITable
|
|
712
|
+
_TN(s: string) :ITable
|
|
712
713
|
}
|
|
713
714
|
|
|
714
715
|
interface IGenericPromise {
|