Skip to content

Commit

Permalink
Implementing #322
Browse files Browse the repository at this point in the history
  • Loading branch information
vitaly-t committed May 10, 2017
1 parent 495f870 commit a0e2197
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 12 deletions.
4 changes: 2 additions & 2 deletions lib/database.js
Expand Up @@ -300,7 +300,7 @@ function Database(cn, dc, config) {
$npm.utils.addReadProp(this, '$cn', cn, true);

/**
* @member {string|object} Database.$dc
* @member {} Database.$dc
* @readonly
* @description
* **Added in v5.6.8**
Expand Down Expand Up @@ -808,7 +808,7 @@ function Database(cn, dc, config) {
* - Use of a custom iterator has a much better performance than the standard {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map Array.map}
* - Automatic `this` context through the database protocol
*
* @param {String|Object} query
* @param {string|object} query
* Query to be executed, which can any of the following types:
* - A non-empty query string
* - Prepared Statement `{name, text, values, ...}` or {@link PreparedStatement} object
Expand Down
2 changes: 1 addition & 1 deletion lib/events.js
Expand Up @@ -476,7 +476,7 @@ var $events = {
/**
* @event unexpected
* @param {string} event - unhandled event name.
* @param {String|Error} e - unhandled error.
* @param {string|Error} e - unhandled error.
* @private
*/
unexpected: (event, e) => {
Expand Down
8 changes: 2 additions & 6 deletions lib/helpers/columnSet.js
Expand Up @@ -235,15 +235,13 @@ function ColumnSet(columns, options) {

/**
* @name helpers.ColumnSet#names
* @type String
* @type string
* @readonly
* @description
* **Added in v5.5.5**
*
* Returns a string - comma-separated list of all column names, properly escaped.
*
* This method is primarily for internal use.
*
* @example
* var cs = new ColumnSet(['id^', {name: 'cells', cast: 'int[]'}, 'doc:json']);
* console.log(cs.names);
Expand All @@ -260,15 +258,13 @@ function ColumnSet(columns, options) {

/**
* @name helpers.ColumnSet#variables
* @type String
* @type string
* @readonly
* @description
* **Added in v5.5.5**
*
* Returns a string - formatting template for all column values.
*
* This method is primarily for internal use.
*
* @example
* var cs = new ColumnSet(['id^', {name: 'cells', cast: 'int[]'}, 'doc:json']);
* console.log(cs.variables);
Expand Down
6 changes: 6 additions & 0 deletions test/typescript/init.ts
@@ -1,4 +1,5 @@
import * as pgPromise from '../../typescript/pg-promise';
import {IConnectionParameters} from "../../typescript/pg-subset";

var pgp: pgPromise.IMain = pgPromise({
capSQL: true,
Expand All @@ -19,6 +20,11 @@ interface Test {

var db = <pgPromise.IDatabase<Test>&Test>pgp('connection');

var connection1:string = <string>db.$cn;
var connection2:IConnectionParameters = <IConnectionParameters>db.$cn;

var context:any = db.$dc;

db.one('');

db.one(new pgPromise.QueryFile(''));
Expand Down
14 changes: 11 additions & 3 deletions typescript/pg-promise.d.ts
@@ -1,5 +1,5 @@
////////////////////////////////////////
// Requires pg-promise v5.6.7 or later.
// Requires pg-promise v5.6.8 or later.
////////////////////////////////////////

import * as XPromise from './ext-promise'; // External Promise Provider
Expand Down Expand Up @@ -288,9 +288,17 @@ declare namespace pgPromise {
interface IDatabase<Ext> extends IBaseProtocol<Ext> {
connect(options?: TConnectionOptions): XPromise<IConnected<Ext>>;

// A hidden property, for integrating with third-party libraries.
/////////////////////////////////////////////////////////////////////////////
// Hidden, read-only properties, for integrating with third-party libraries:

// API: http://vitaly-t.github.io/pg-promise/Database.html#$config
$config: ILibConfig<Ext>;
readonly $config: ILibConfig<Ext>;

// API: http://vitaly-t.github.io/pg-promise/Database.html#$cn
readonly $cn: string|IConfig;

// API: http://vitaly-t.github.io/pg-promise/Database.html#$dc
readonly $dc: any;
}

type IConfig = pg.IConnectionParameters;
Expand Down

0 comments on commit a0e2197

Please sign in to comment.