2024-02-10 19:05:08 +00:00
|
|
|
package handlers
|
|
|
|
|
|
|
|
import (
|
2024-06-01 00:10:20 +01:00
|
|
|
"fmt"
|
2024-02-10 19:05:08 +00:00
|
|
|
"net/http"
|
|
|
|
|
|
|
|
"github.com/gin-gonic/gin"
|
|
|
|
"github.com/pikami/cosmium/internal/repositories"
|
2024-02-12 19:38:03 +00:00
|
|
|
repositorymodels "github.com/pikami/cosmium/internal/repository_models"
|
2024-02-10 19:05:08 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func GetAllTriggers(c *gin.Context) {
|
|
|
|
databaseId := c.Param("databaseId")
|
|
|
|
collectionId := c.Param("collId")
|
|
|
|
|
|
|
|
triggers, status := repositories.GetAllTriggers(databaseId, collectionId)
|
|
|
|
|
2024-02-12 19:38:03 +00:00
|
|
|
if status == repositorymodels.StatusOk {
|
2024-06-01 00:10:20 +01:00
|
|
|
c.Header("x-ms-item-count", fmt.Sprintf("%d", len(triggers)))
|
2024-02-10 19:05:08 +00:00
|
|
|
c.IndentedJSON(http.StatusOK, gin.H{"_rid": "", "Triggers": triggers, "_count": len(triggers)})
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
c.IndentedJSON(http.StatusInternalServerError, gin.H{"message": "Unknown error"})
|
|
|
|
}
|