inspect search bug
This commit is contained in:
parent
a4a249bab8
commit
450fab437c
@ -125,6 +125,7 @@ func genericLoadAll[T DBObject](res *mgb.Cursor, code int, err error, onlyDraft
|
|||||||
return nil, 404, err
|
return nil, 404, err
|
||||||
}
|
}
|
||||||
for _, r := range results {
|
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()) {
|
if !r.VerifyAuth(a.GetRequest()) || f(r) == nil || (onlyDraft && !r.IsDrafted()) || (!onlyDraft && r.IsDrafted()) {
|
||||||
continue
|
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) {
|
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())
|
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)
|
return genericLoadAll[T](res_mongo, code, err, onlyDraft, f, wfa)
|
||||||
}
|
}
|
||||||
|
|
||||||
func GenericSearch[T DBObject](filters *dbs.Filters, search string, defaultFilters *dbs.Filters,
|
func GenericSearch[T DBObject](filters *dbs.Filters, search string, defaultFilters *dbs.Filters,
|
||||||
f func(DBObject) ShallowDBObject, onlyDraft bool, wfa Accessor) ([]ShallowDBObject, int, error) {
|
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
|
filters = defaultFilters
|
||||||
}
|
}
|
||||||
res_mongo, code, err := mongo.MONGOService.Search(filters, wfa.GetType().String())
|
res_mongo, code, err := mongo.MONGOService.Search(filters, wfa.GetType().String())
|
||||||
|
Loading…
Reference in New Issue
Block a user