mirror of
https://github.com/pikami/cosmium.git
synced 2025-12-19 00:40:47 +00:00
Generate legit ResourceIds for SDK compatibility
This commit is contained in:
@@ -13,7 +13,13 @@ func GetAllCollections(c *gin.Context) {
|
||||
|
||||
collections, status := repositories.GetAllCollections(databaseId)
|
||||
if status == repositorymodels.StatusOk {
|
||||
c.IndentedJSON(http.StatusOK, gin.H{"_rid": "", "DocumentCollections": collections, "_count": len(collections)})
|
||||
database, _ := repositories.GetDatabase(databaseId)
|
||||
|
||||
c.IndentedJSON(http.StatusOK, gin.H{
|
||||
"_rid": database.ResourceID,
|
||||
"DocumentCollections": collections,
|
||||
"_count": len(collections),
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -11,7 +11,11 @@ import (
|
||||
func GetAllDatabases(c *gin.Context) {
|
||||
databases, status := repositories.GetAllDatabases()
|
||||
if status == repositorymodels.StatusOk {
|
||||
c.IndentedJSON(http.StatusOK, gin.H{"_rid": "", "Databases": databases, "_count": len(databases)})
|
||||
c.IndentedJSON(http.StatusOK, gin.H{
|
||||
"_rid": "",
|
||||
"Databases": databases,
|
||||
"_count": len(databases),
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -15,7 +15,13 @@ func GetAllDocuments(c *gin.Context) {
|
||||
|
||||
documents, status := repositories.GetAllDocuments(databaseId, collectionId)
|
||||
if status == repositorymodels.StatusOk {
|
||||
c.IndentedJSON(http.StatusOK, gin.H{"_rid": "", "Documents": documents, "_count": len(documents)})
|
||||
collection, _ := repositories.GetCollection(databaseId, collectionId)
|
||||
|
||||
c.IndentedJSON(http.StatusOK, gin.H{
|
||||
"_rid": collection.ID,
|
||||
"Documents": documents,
|
||||
"_count": len(documents),
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
@@ -121,7 +127,12 @@ func DocumentsPost(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
c.IndentedJSON(http.StatusOK, gin.H{"_rid": "", "Documents": docs, "_count": len(docs)})
|
||||
collection, _ := repositories.GetCollection(databaseId, collectionId)
|
||||
c.IndentedJSON(http.StatusOK, gin.H{
|
||||
"_rid": collection.ResourceID,
|
||||
"Documents": docs,
|
||||
"_count": len(docs),
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -26,8 +26,9 @@ func GetPartitionKeyRanges(c *gin.Context) {
|
||||
c.Header("x-ms-global-committed-lsn", "420")
|
||||
c.Header("x-ms-item-count", fmt.Sprintf("%d", len(partitionKeyRanges)))
|
||||
|
||||
collection, _ := repositories.GetCollection(databaseId, collectionId)
|
||||
c.IndentedJSON(http.StatusOK, gin.H{
|
||||
"_rid": "",
|
||||
"_rid": collection.ResourceID,
|
||||
"_count": len(partitionKeyRanges),
|
||||
"PartitionKeyRanges": partitionKeyRanges,
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user