Description
Add the FindAll method in
|
func (m *ResourceModel) FindAll(resourceType string) ([]string, error) { |
impelementation for
BadgerDB. This method is responsible for retrieving the full data content of all resources belonging to a specific type from the local key-value store.
Requirements
- File Location:
internal/models/resource.go
- Transactionality: Use a BadgerDB View (read-only) transaction.
- Prefix Scanning & Value Retrieval:
- Utilize a BadgerDB Iterator to scan for all keys starting with the prefix:
/resources/{resourceType}/.
- Unlike the
List method, this method must retrieve the Value associated with each key.
- The implementation must include logic to filter out versioned sub-keys (e.g.,
/resources/type/name/1) to ensure only the primary resource objects are returned in the result set.
- Data Extraction: Collect the values as a slice of strings (representing JSON data).
- Error Handling: If no resources are found for the given type, return a "no resources found" error to maintain parity with the current implementation.
- Dependency Injection: The method must use the injected
*badger.DB instance.
- Testing: A corresponding test case must be created in
internal/models/resource_test.go.
Success Criteria
Description
Add the
FindAllmethod inconveyor/internal/models/resource.go
Line 159 in 2572f4c
BadgerDB. This method is responsible for retrieving the full data content of all resources belonging to a specific type from the local key-value store.Requirements
internal/models/resource.go/resources/{resourceType}/.Listmethod, this method must retrieve the Value associated with each key./resources/type/name/1) to ensure only the primary resource objects are returned in the result set.*badger.DBinstance.internal/models/resource_test.go.Success Criteria
FindAllmethod successfully iterates through BadgerDB and retrieves full resource values.FindAllfor that type.