File tree Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Original file line number Diff line number Diff line change @@ -24,6 +24,12 @@ type (
24
24
query * string ,
25
25
params ... interface {},
26
26
) (* pgconn.CommandTag , error )
27
+ Query (query * string , params ... interface {}) (pgx.Rows , error )
28
+ QueryWithCtx (
29
+ ctx context.Context ,
30
+ query * string ,
31
+ params ... interface {},
32
+ ) (pgx.Rows , error )
27
33
QueryRow (query * string , params ... interface {}) pgx.Row
28
34
QueryRowWithCtx (
29
35
ctx context.Context ,
@@ -143,6 +149,29 @@ func (d *DefaultService) QueryRowWithCtx(
143
149
return d .pool .QueryRow (ctx , * query , params ... )
144
150
}
145
151
152
+ // QueryWithCtx runs a query with parameters and returns the result with a context
153
+ func (d * DefaultService ) QueryWithCtx (
154
+ ctx context.Context ,
155
+ query * string ,
156
+ params ... interface {},
157
+ ) (pgx.Rows , error ) {
158
+ // Check if the query is nil
159
+ if query == nil {
160
+ return nil , godatabases .ErrNilQuery
161
+ }
162
+
163
+ // Run the query
164
+ return d .pool .Query (ctx , * query , params ... )
165
+ }
166
+
167
+ // Query runs a query with parameters and returns the result
168
+ func (d * DefaultService ) Query (
169
+ query * string ,
170
+ params ... interface {},
171
+ ) (pgx.Rows , error ) {
172
+ return d .QueryWithCtx (context .Background (), query , params ... )
173
+ }
174
+
146
175
// QueryRow runs a query row with parameters and returns the result row
147
176
func (d * DefaultService ) QueryRow (
148
177
query * string ,
You can’t perform that action at this time.
0 commit comments