File tree Expand file tree Collapse file tree 3 files changed +15
-6
lines changed
Expand file tree Collapse file tree 3 files changed +15
-6
lines changed Original file line number Diff line number Diff line change @@ -58,10 +58,12 @@ export class QueryBuilder<GenericResult, GenericResultOne> {
5858 args = args . concat ( this . _parse_arguments ( params . data ) )
5959 }
6060
61+ const fetchType = Array . isArray ( params . data ) ? FetchTypes . ALL : FetchTypes . ONE
62+
6163 return this . execute ( {
6264 query : this . _insert ( params ) ,
6365 arguments : args ,
64- fetchType : Array . isArray ( params . data ) ? FetchTypes . ALL : FetchTypes . ONE ,
66+ fetchType : fetchType ,
6567 } )
6668 }
6769
Original file line number Diff line number Diff line change @@ -22,10 +22,17 @@ export class D1QB extends QueryBuilder<D1Result, D1ResultOne> {
2222 stmt = stmt . bind ( ...params . arguments )
2323 }
2424
25- if ( params . fetchType === FetchTypes . ONE ) {
26- return stmt . first ( )
27- } else if ( params . fetchType === FetchTypes . ALL ) {
28- return stmt . all ( )
25+ if ( params . fetchType === FetchTypes . ONE || params . fetchType === FetchTypes . ALL ) {
26+ const resp = await stmt . all ( )
27+
28+ return {
29+ changes : resp . meta ?. changes ,
30+ duration : resp . meta ?. duration ,
31+ last_row_id : resp . meta ?. last_row_id ,
32+ served_by : resp . meta ?. served_by ,
33+ success : resp . success ,
34+ results : params . fetchType === FetchTypes . ONE && resp . results . length > 0 ? resp . results [ 0 ] : resp . results ,
35+ }
2936 }
3037
3138 return stmt . run ( )
Original file line number Diff line number Diff line change @@ -45,7 +45,7 @@ export class PGQB extends QueryBuilder<PGResult, PGResultOne> {
4545 command : result . command ,
4646 lastRowId : result . oid ,
4747 rowCount : result . rowCount ,
48- results : result . rows ,
48+ results : params . fetchType === FetchTypes . ONE && result . rows . length > 0 ? result . rows [ 0 ] : result . rows ,
4949 }
5050 }
5151
You can’t perform that action at this time.
0 commit comments