mirror of
https://github.com/pikami/cosmium.git
synced 2025-12-19 08:50:46 +00:00
Code cleanup; Implement persistant storage; Use maps for storage
This commit is contained in:
@@ -65,14 +65,14 @@ func CreateDatabase(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
status := repositories.CreateDatabase(newDatabase)
|
||||
createdDatabase, status := repositories.CreateDatabase(newDatabase)
|
||||
if status == repositorymodels.Conflict {
|
||||
c.IndentedJSON(http.StatusConflict, gin.H{"message": "Conflict"})
|
||||
return
|
||||
}
|
||||
|
||||
if status == repositorymodels.StatusOk {
|
||||
c.IndentedJSON(http.StatusCreated, newDatabase)
|
||||
c.IndentedJSON(http.StatusCreated, createdDatabase)
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -78,14 +78,14 @@ func ReplaceDocument(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
status = repositories.CreateDocument(databaseId, collectionId, requestBody)
|
||||
createdDocument, status := repositories.CreateDocument(databaseId, collectionId, requestBody)
|
||||
if status == repositorymodels.Conflict {
|
||||
c.IndentedJSON(http.StatusConflict, gin.H{"message": "Conflict"})
|
||||
return
|
||||
}
|
||||
|
||||
if status == repositorymodels.StatusOk {
|
||||
c.IndentedJSON(http.StatusCreated, requestBody)
|
||||
c.IndentedJSON(http.StatusCreated, createdDocument)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -114,7 +114,6 @@ func DocumentsPost(c *gin.Context) {
|
||||
queryParameters = parametersToMap(paramsArray)
|
||||
}
|
||||
|
||||
// TODO: Handle these {"query":"select c.id, c._self, c._rid, c._ts, [c[\"pk\"]] as _partitionKeyValue from c"}
|
||||
docs, status := repositories.ExecuteQueryDocuments(databaseId, collectionId, query.(string), queryParameters)
|
||||
if status != repositorymodels.StatusOk {
|
||||
// TODO: Currently we return everything if the query fails
|
||||
@@ -131,14 +130,14 @@ func DocumentsPost(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
status := repositories.CreateDocument(databaseId, collectionId, requestBody)
|
||||
createdDocument, status := repositories.CreateDocument(databaseId, collectionId, requestBody)
|
||||
if status == repositorymodels.Conflict {
|
||||
c.IndentedJSON(http.StatusConflict, gin.H{"message": "Conflict"})
|
||||
return
|
||||
}
|
||||
|
||||
if status == repositorymodels.StatusOk {
|
||||
c.IndentedJSON(http.StatusCreated, requestBody)
|
||||
c.IndentedJSON(http.StatusCreated, createdDocument)
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -24,6 +24,9 @@ func RegisterExplorerHandlers(router *gin.Engine) {
|
||||
ctx.Next()
|
||||
}
|
||||
})
|
||||
explorer.Static("/", config.Config.ExplorerPath)
|
||||
|
||||
if config.Config.ExplorerPath != "" {
|
||||
explorer.Static("/", config.Config.ExplorerPath)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user