adding search func

This commit is contained in:
mr
2024-07-26 13:45:10 +02:00
parent 6c83e54d37
commit 8c97fca96c
12 changed files with 170 additions and 1 deletions

View File

@@ -149,3 +149,20 @@ func (wfa WorkflowMongoAccessor) LoadAll() ([]utils.ShallowDBObject, int, error)
}
return objs, 200, nil
}
func (wfa *WorkflowMongoAccessor) Search(word string) ([]utils.ShallowDBObject, int, error) {
objs := []utils.ShallowDBObject{}
res_mongo, code, err := mongo.MONGOService.Search(word, []string{"name"}, wfa.GetType())
if err != nil {
wfa.Logger.Error().Msg("Could not store to db. Error: " + err.Error())
return nil, code, err
}
var results []Workflow
if err = res_mongo.All(mongo.MngoCtx, &results); err != nil {
return nil, 404, err
}
for _, r := range results {
objs = append(objs, &r)
}
return objs, 200, nil
}

View File

@@ -4,7 +4,7 @@ import "time"
type WorkflowSchedule struct {
Id string `json:"id"`
Start time.Time `json:"start" bson:"start validate:"required""`
Start time.Time `json:"start" bson:"start" validate:"required"`
End time.Time `json:"end,omitempty" bson:"end,omitempty"`
Cron string `json:"cron,omitempty" bson:"cron,omitempty"`
}