go-duck-cli 1.1.22 → 1.1.23

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -342,6 +342,7 @@ func CORSMiddleware(cfg *config.Config) gin.HandlerFunc {
342
342
  }
343
343
 
344
344
  c.Writer.Header().Set("Access-Control-Allow-Credentials", "true")
345
+ c.Writer.Header().Set("Access-Control-Expose-Headers", "X-Total-Count")
345
346
 
346
347
  headerString := ""
347
348
  for i, h := range headers {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "go-duck-cli",
3
- "version": "1.1.22",
3
+ "version": "1.1.23",
4
4
  "description": "The Ultimate Evolutionary Go Microservice Scaffolder.",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -181,8 +181,6 @@ func (ctrl *{{capitalize name}}Controller) GetAll(c *gin.Context) {
181
181
 
182
182
  db, _ := c.Get("tenantMongoDB")
183
183
  tenantDB := db.(*mongo.Database)
184
- var entities []models.{{capitalize name}}
185
- opts := options.Find().SetSkip(int64(page * size)).SetLimit(int64(size))
186
184
 
187
185
  // PostgREST-lite Filter Translation (Simple eq check for now)
188
186
  filter := bson.M{}
@@ -192,6 +190,11 @@ func (ctrl *{{capitalize name}}Controller) GetAll(c *gin.Context) {
192
190
  }
193
191
  }
194
192
 
193
+ totalCount, _ := tenantDB.Collection("{{toLowerCase name}}s").CountDocuments(ctx, filter)
194
+ c.Header("X-Total-Count", strconv.FormatInt(totalCount, 10))
195
+
196
+ var entities []models.{{capitalize name}}
197
+ opts := options.Find().SetSkip(int64(page * size)).SetLimit(int64(size))
195
198
  cursor, err := tenantDB.Collection("{{toLowerCase name}}s").Find(ctx, filter, opts)
196
199
  if err != nil {
197
200
  c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
@@ -232,6 +235,13 @@ func (ctrl *{{capitalize name}}Controller) GetAll(c *gin.Context) {
232
235
  }
233
236
  {{/if}}
234
237
 
238
+ var totalCount int64
239
+ if err := tenantDB.WithContext(ctx).Model(&models.{{capitalize name}}{}).Count(&totalCount).Error; err != nil {
240
+ c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
241
+ return
242
+ }
243
+ c.Header("X-Total-Count", strconv.FormatInt(totalCount, 10))
244
+
235
245
  var entities []models.{{capitalize name}}
236
246
  if err := tenantDB.WithContext(ctx).Offset(page * size).Limit(size).Find(&entities).Error; err != nil {
237
247
  c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})