mirror of
https://github.com/pikami/cosmium.git
synced 2025-12-19 08:50:46 +00:00
Added get APIs for Stored Procedures, Triggers and User Defined Functions
This commit is contained in:
@@ -6,7 +6,7 @@ var collections = []Collection{
|
||||
}
|
||||
|
||||
func GetAllCollections(databaseId string) ([]Collection, RepositoryStatus) {
|
||||
var dbCollections []Collection
|
||||
dbCollections := make([]Collection, 0)
|
||||
|
||||
for _, coll := range collections {
|
||||
if coll.internals.databaseId == databaseId {
|
||||
|
||||
@@ -45,3 +45,44 @@ type Collection struct {
|
||||
databaseId string
|
||||
}
|
||||
}
|
||||
|
||||
type UserDefinedFunction struct {
|
||||
Body string `json:"body"`
|
||||
ID string `json:"id"`
|
||||
Rid string `json:"_rid"`
|
||||
Ts int `json:"_ts"`
|
||||
Self string `json:"_self"`
|
||||
Etag string `json:"_etag"`
|
||||
internals struct {
|
||||
databaseId string
|
||||
collectionId string
|
||||
}
|
||||
}
|
||||
|
||||
type StoredProcedure struct {
|
||||
Body string `json:"body"`
|
||||
ID string `json:"id"`
|
||||
Rid string `json:"_rid"`
|
||||
Ts int `json:"_ts"`
|
||||
Self string `json:"_self"`
|
||||
Etag string `json:"_etag"`
|
||||
internals struct {
|
||||
databaseId string
|
||||
collectionId string
|
||||
}
|
||||
}
|
||||
|
||||
type Trigger struct {
|
||||
Body string `json:"body"`
|
||||
ID string `json:"id"`
|
||||
TriggerOperation string `json:"triggerOperation"`
|
||||
TriggerType string `json:"triggerType"`
|
||||
Rid string `json:"_rid"`
|
||||
Ts int `json:"_ts"`
|
||||
Self string `json:"_self"`
|
||||
Etag string `json:"_etag"`
|
||||
internals struct {
|
||||
databaseId string
|
||||
collectionId string
|
||||
}
|
||||
}
|
||||
|
||||
15
internal/repositories/stored_procedures.go
Normal file
15
internal/repositories/stored_procedures.go
Normal file
@@ -0,0 +1,15 @@
|
||||
package repositories
|
||||
|
||||
var storedProcedures = []StoredProcedure{}
|
||||
|
||||
func GetAllStoredProcedures(databaseId string, collectionId string) ([]StoredProcedure, RepositoryStatus) {
|
||||
sps := make([]StoredProcedure, 0)
|
||||
|
||||
for _, coll := range storedProcedures {
|
||||
if coll.internals.databaseId == databaseId && coll.internals.collectionId == collectionId {
|
||||
sps = append(sps, coll)
|
||||
}
|
||||
}
|
||||
|
||||
return sps, StatusOk
|
||||
}
|
||||
15
internal/repositories/triggers.go
Normal file
15
internal/repositories/triggers.go
Normal file
@@ -0,0 +1,15 @@
|
||||
package repositories
|
||||
|
||||
var triggers = []Trigger{}
|
||||
|
||||
func GetAllTriggers(databaseId string, collectionId string) ([]Trigger, RepositoryStatus) {
|
||||
sps := make([]Trigger, 0)
|
||||
|
||||
for _, coll := range triggers {
|
||||
if coll.internals.databaseId == databaseId && coll.internals.collectionId == collectionId {
|
||||
sps = append(sps, coll)
|
||||
}
|
||||
}
|
||||
|
||||
return sps, StatusOk
|
||||
}
|
||||
15
internal/repositories/user_defined_functions.go
Normal file
15
internal/repositories/user_defined_functions.go
Normal file
@@ -0,0 +1,15 @@
|
||||
package repositories
|
||||
|
||||
var userDefinedFunctions = []UserDefinedFunction{}
|
||||
|
||||
func GetAllUserDefinedFunctions(databaseId string, collectionId string) ([]UserDefinedFunction, RepositoryStatus) {
|
||||
udfs := make([]UserDefinedFunction, 0)
|
||||
|
||||
for _, coll := range userDefinedFunctions {
|
||||
if coll.internals.databaseId == databaseId && coll.internals.collectionId == collectionId {
|
||||
udfs = append(udfs, coll)
|
||||
}
|
||||
}
|
||||
|
||||
return udfs, StatusOk
|
||||
}
|
||||
Reference in New Issue
Block a user