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

@@ -52,3 +52,20 @@ func (wfa WorkflowExecutionMongoAccessor) LoadAll() ([]utils.ShallowDBObject, in
}
return objs, 200, nil
}
func (wfa *WorkflowExecutionMongoAccessor) Search(word string) ([]utils.ShallowDBObject, int, error) {
objs := []utils.ShallowDBObject{}
res_mongo, code, err := mongo.MONGOService.Search(word, []string{}, wfa.GetType())
if err != nil {
wfa.Logger.Error().Msg("Could not store to db. Error: " + err.Error())
return nil, code, err
}
var results []WorkflowExecution
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
}