Initial cloud-services repo - gateway service + pkg modules

This commit is contained in:
Chris Rai
2026-01-30 23:14:52 -05:00
commit fbb820d7b3
1037 changed files with 171318 additions and 0 deletions

30
pkg/mongo/sort.go Normal file
View File

@@ -0,0 +1,30 @@
package mongo
import (
"strings"
"go.mongodb.org/mongo-driver/bson"
)
func AdaptOrder(orderString string, adaptMap map[string]string) string {
for old, new := range adaptMap {
orderString = strings.Replace(orderString, old, new, -1)
}
return orderString
}
func getOrder(queryOrder string) bson.M {
order := bson.M{"_id": -1}
orderSlice := strings.Split(queryOrder, " ")
if len(orderSlice) > 1 {
asc := 1
if strings.ToLower(orderSlice[1]) == "desc" {
asc = -1
}
order = bson.M{orderSlice[0]: asc}
}
return order
}