clover
Last updated: 2025-06-06 01:05:26.510662 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
GenericRepository
interface for CloverDB, providing CRUD operations and query functionality.generic_repo_test.go: Contains tests for the
GenericRepository
implementation.generic_entity_repository.go: Implements the
GenericEntityRepository
interface for CloverDB, providing operations for repositories handling a single record.entity_repo_test.go: Contains tests for the
GenericEntityRepository
implementation.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
Implementation 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
GenericRepository
that handles CRUD operations and queries.CloverEntityRepository: The implementation of
GenericEntityRepository
for 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:
Last updated