Description
Add the List method BadgerDB implementation in
|
func (m *ResourceModel) List(resourceType string) ([]string, error) { |
. This method is responsible for scanning the database for all keys associated with a specific resource type and returning a list of their names (keys).
Requirements
- File Location:
internal/models/resource.go
- Transactionality: Use a BadgerDB View (read-only) transaction.
- Prefix Scanning: * Utilize a BadgerDB Iterator to scan for keys starting with the prefix:
/resources/{resourceType}/.
- The implementation must ensure it only collects the primary resource keys and handles the logic to filter out or include versioned sub-keys based on the existing application expectations.
- Data Extraction: Extract and collect the keys as a slice of strings (
[]string).
- 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
ListmethodBadgerDBimplementation inconveyor/internal/models/resource.go
Line 94 in 2572f4c
Requirements
internal/models/resource.go/resources/{resourceType}/.[]string).*badger.DBinstance.internal/models/resource_test.go.Success Criteria
Listmethod successfully performs a prefix scan on the BadgerDB store.resourceType.Listfor a specific type.