Merge pull request #24009 from alex-sherwin/master

Existing "QueryResult" interface is  missing property "fields"
This commit is contained in:
Benjamin Lichtman
2018-03-02 16:34:35 -08:00
committed by GitHub
2 changed files with 11 additions and 9 deletions
+9 -9
View File
@@ -53,13 +53,6 @@ export interface QueryArrayConfig extends QueryConfig {
rowMode: 'array';
}
export interface QueryResult {
command: string;
rowCount: number;
oid: number;
rows: any[];
}
export interface FieldDef {
name: string;
tableID: number;
@@ -70,14 +63,21 @@ export interface FieldDef {
format: string;
}
export interface QueryArrayResult {
export interface QueryResultBase {
command: string;
rowCount: number;
oid: number;
rows: any[][];
fields: FieldDef[];
}
export interface QueryResult extends QueryResultBase {
rows: any[];
}
export interface QueryArrayResult extends QueryResultBase {
rows: any[][];
}
export interface Notification {
processId: number;
channel: string;
+2
View File
@@ -55,11 +55,13 @@ client.query(query, (err, res) => {
console.error(err.stack);
} else {
console.log(res.rows);
console.log(res.fields.map(f => f.name));
}
});
client.query(query)
.then(res => {
console.log(res.rows);
console.log(res.fields.map(f => f.name));
})
.catch(e => {
console.error(e.stack);