feat: added modules

This commit is contained in:
Marvin Zhang
2024-06-14 15:42:50 +08:00
parent f1833fed21
commit 0b67fd9ece
626 changed files with 60104 additions and 0 deletions

27
core/utils/sql.go Normal file
View File

@@ -0,0 +1,27 @@
package utils
import (
"github.com/crawlab-team/crawlab-db/generic"
"github.com/upper/db/v4"
"go.mongodb.org/mongo-driver/bson/primitive"
)
func GetSqlQuery(query generic.ListQuery) (res db.Cond) {
res = db.Cond{}
for _, c := range query {
switch c.Value.(type) {
case primitive.ObjectID:
c.Value = c.Value.(primitive.ObjectID).Hex()
}
switch c.Op {
case generic.OpEqual:
res[c.Key] = c.Value
default:
res[c.Key] = db.Cond{
c.Op: c.Value,
}
}
}
// TODO: sort
return res
}