From 450fab437cb7854250ac441bae21c09192565ed3 Mon Sep 17 00:00:00 2001 From: mr Date: Fri, 17 Jan 2025 09:16:40 +0100 Subject: [PATCH] inspect search bug --- models/utils/common.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/models/utils/common.go b/models/utils/common.go index 5c0409a..4d17ceb 100644 --- a/models/utils/common.go +++ b/models/utils/common.go @@ -125,6 +125,7 @@ func genericLoadAll[T DBObject](res *mgb.Cursor, code int, err error, onlyDraft return nil, 404, err } for _, r := range results { + fmt.Println(!r.VerifyAuth(a.GetRequest()), f(r), r.IsDrafted()) if !r.VerifyAuth(a.GetRequest()) || f(r) == nil || (onlyDraft && !r.IsDrafted()) || (!onlyDraft && r.IsDrafted()) { continue } @@ -135,13 +136,12 @@ func genericLoadAll[T DBObject](res *mgb.Cursor, code int, err error, onlyDraft func GenericLoadAll[T DBObject](f func(DBObject) ShallowDBObject, onlyDraft bool, wfa Accessor) ([]ShallowDBObject, int, error) { res_mongo, code, err := mongo.MONGOService.LoadAll(wfa.GetType().String()) - fmt.Println("res_mongo", res_mongo) return genericLoadAll[T](res_mongo, code, err, onlyDraft, f, wfa) } func GenericSearch[T DBObject](filters *dbs.Filters, search string, defaultFilters *dbs.Filters, f func(DBObject) ShallowDBObject, onlyDraft bool, wfa Accessor) ([]ShallowDBObject, int, error) { - if (filters == nil || len(filters.And) == 0 || len(filters.Or) == 0) && search != "" { + if filters == nil && search != "" { filters = defaultFilters } res_mongo, code, err := mongo.MONGOService.Search(filters, wfa.GetType().String())