clover
Last updated: 2025-10-30 01:14:44.307974 File source: link on GitLab
clover
Table of Contents
Specification
Description
The clover package provides a NoSQL document-oriented database implementation of the repository interfaces defined in the parent db package. It uses CloverDB as the underlying storage engine and implements both the GenericRepository and GenericEntityRepository interfaces.
Structure and Organisation
Here is a quick overview of the contents of this package:
README.md: Current file which is aimed towards developers who wish to use and modify the CloverDB implementation.
clover.go: Contains the CloverDB connection and initialization logic.
clover_test.go: Contains tests for the CloverDB connection and initialization.
generic_repository.go: Implements the
GenericRepositoryinterface for CloverDB, providing CRUD operations and query functionality.generic_repo_test.go: Contains tests for the
GenericRepositoryimplementation.generic_entity_repository.go: Implements the
GenericEntityRepositoryinterface for CloverDB, providing operations for repositories handling a single record.entity_repo_test.go: Contains tests for the
GenericEntityRepositoryimplementation.utils.go: Contains utility functions specific to the CloverDB implementation.
utils_test.go: Contains tests for the utility functions.
log.go: Contains logging functionality for the CloverDB implementation.
specs: This folder contains the class diagram of the package.
Class Diagram
The class diagram for the clover package is shown below.
Source file
Rendered from source file
!$rootUrlGitlab = "https://gitlab.com/nunet/device-management-service/-/raw/main"
!$packageRelativePath = "/db/clover"
!$packageUrlGitlab = $rootUrlGitlab + $packageRelativePath
!include $packageUrlGitlab/specs/class_diagram.pumlImplementation Details
CloverDB Repository
The CloverDB implementation provides a document-oriented storage solution with the following key features:
Document Storage: Data is stored as JSON documents in collections.
Type Safety: Uses Go generics to ensure type safety when working with different data types.
Query Capabilities: Supports complex queries using the query condition functions (EQ, GT, GTE, LT, LTE, IN, LIKE).
Transactions: Provides transaction support for atomic operations.
History Tracking: For
GenericEntityRepository, maintains a history of changes to records.
Key Components
CloverRepository: The main implementation of
GenericRepositorythat handles CRUD operations and queries.CloverEntityRepository: The implementation of
GenericEntityRepositoryfor single-record repositories.CloverDB Connection: Manages the connection to the underlying CloverDB database.
Testing
The package includes comprehensive tests for all components:
Unit Tests: Tests for individual functions and methods.
Integration Tests: Tests that verify the interaction between different components.
Repository Tests: Tests that verify the repository implementations meet the interface requirements.
To run the tests for this package, use the following command:
go test -v ./db/clover/...Last updated

