Shallow Get All

This commit is contained in:
mr
2024-07-23 11:22:50 +02:00
parent a687206a1b
commit 94cd62acfe
10 changed files with 119 additions and 14 deletions

View File

@@ -197,3 +197,17 @@ func (m *MongoDB) LoadOne(id string, collection_name string) (*mongo.SingleResul
}
return res, 200, nil
}
func (m *MongoDB) LoadAll(collection_name string) (*mongo.Cursor, int, error) {
targetDBCollection := CollectionMap[collection_name]
MngoCtx, cancel = context.WithTimeout(context.Background(), 10*time.Second)
defer cancel()
res, err := targetDBCollection.Find(MngoCtx, bson.D{})
if err != nil {
m.Logger.Error().Msg("Couldn't find any resources. Error : " + err.Error())
return nil, 404, err
}
return res, 200, nil
}