Skip to content

Commit 119aa73

Browse files
author
Laszlo Radics
committed
feat: new query function queryAsRows which gives result as array instead of objects
1 parent b125807 commit 119aa73

10 files changed

+83
-35
lines changed

lib/pgDb.d.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,6 @@ export declare class PgDb extends QueryAble {
7373
private listeners;
7474
listen(channel: string, callback: (notification: Notification) => void): Promise<void>;
7575
unlisten(channel: string, callback?: (Notification: any) => void): Promise<void>;
76-
notify(channel: string, payload?: string): Promise<any>;
76+
notify(channel: string, payload?: string): Promise<any[]>;
7777
}
7878
export default PgDb;

lib/pgUtils.d.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ export declare let pgUtils: {
1717
processQueryOptions(options: QueryOptions): string;
1818
transformInsertUpdateParams(param: any, fieldType: FieldType): any;
1919
postProcessResult(res: any[], fields: ResultFieldType[], pgdbTypeParsers: {
20-
[oid: number]: (string: any) => any;
20+
[oid: number]: (s: string) => any;
2121
}): void;
2222
convertTypes(res: any[], fields: ResultFieldType[], pgdbTypeParsers: {
23-
[oid: number]: (string: any) => any;
23+
[oid: number]: (s: string) => any;
2424
}): void;
2525
createFunctionCaller(q: QueryAble, fn: {
2626
schema: string;

lib/pgUtils.js

+11-9
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/pgUtils.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/queryAble.d.ts

+13-1
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ export interface ResultType {
3737
rowsAsArray: boolean;
3838
_getTypeParser: Function[];
3939
}
40+
export interface PgRowResult {
41+
columns: string[];
42+
rows: any[];
43+
}
4044
export declare class QueryAble {
4145
db: any;
4246
schema: any;
@@ -51,7 +55,15 @@ export declare class QueryAble {
5155
sql: string;
5256
params?: any;
5357
logger?: any;
54-
}): Promise<any>;
58+
}): Promise<any[]>;
59+
protected internalQuery(options: {
60+
connection: any;
61+
sql: string;
62+
params?: any;
63+
logger?: any;
64+
rowMode: true;
65+
}): Promise<PgRowResult>;
66+
queryAsRows(sql: string, params?: any[] | {}, options?: SqlQueryOptions): Promise<PgRowResult>;
5567
queryWithOnCursorCallback(sql: string, params: any[] | {}, options: SqlQueryOptions, callback: (any: any) => any): Promise<void>;
5668
queryAsStream(sql: string, params?: any[] | {}, options?: SqlQueryOptions): Promise<stream.Readable>;
5769
queryOne(sql: string, params?: any[] | {}, options?: SqlQueryOptions): Promise<any>;

lib/queryAble.js

+11-4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)