File tree 2 files changed +6
-4
lines changed
2 files changed +6
-4
lines changed Original file line number Diff line number Diff line change @@ -84,7 +84,7 @@ func registerRoutes(r chi.Router, db *sqlx.DB) {
84
84
return
85
85
}
86
86
87
- var result []CategoryDto
87
+ result := []CategoryDto {}
88
88
args := map [string ]interface {}{
89
89
"limit" : r .URL .Query ().Get ("limit" ),
90
90
}
Original file line number Diff line number Diff line change @@ -175,7 +175,9 @@ endpoints.forEach(function(endpoint) {
175
175
// LATER: do we really need signature and cache?
176
176
const cacheKey = dto ? dto .signature : null ;
177
177
const dtoName = dtoInCache (dto) ? dtoCache[cacheKey] : dto .name ;
178
- const dataType = hasGetMany ? ' []' + dtoName : dtoName;
178
+ const resultVariableDeclaration = hasGetMany
179
+ ? ` result := []${ dtoName} \{\} `
180
+ : ` var result ${ dtoName} ` ;
179
181
180
182
const queryFunction = hasGetOne ? ' Get' : ' Select' ;
181
183
// LATER: handle only particular method (get/post/put)
@@ -192,13 +194,13 @@ endpoints.forEach(function(endpoint) {
192
194
return
193
195
}
194
196
195
- var result < %- dataType % >
197
+ < %- resultVariableDeclaration % >
196
198
args := map[string]interface {}{
197
199
< %- /* LATER: extract */ params .map (p => ` "${ p .substring (2 )} ": ${ placeholdersMap[' go' ][p .substring (0 , 1 )](p .substring (2 ))} ,` ).join (' \n\t\t\t ' ) % >
198
200
}
199
201
err = stmt.< %- queryFunction % > (& result, args)
200
202
< % } else { -% >
201
- var result < %- dataType % >
203
+ < %- resultVariableDeclaration % >
202
204
err := db.< %- queryFunction % > (& result, " <%- formatQuery(method.query) %>" )
203
205
< % } -% >
204
206
switch err {
You can’t perform that action at this time.
0 commit comments