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

clover Class diagram

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.puml

Implementation Details

CloverDB Repository

The CloverDB implementation provides a document-oriented storage solution with the following key features:

  1. Document Storage: Data is stored as JSON documents in collections.

  2. Type Safety: Uses Go generics to ensure type safety when working with different data types.

  3. Query Capabilities: Supports complex queries using the query condition functions (EQ, GT, GTE, LT, LTE, IN, LIKE).

  4. Transactions: Provides transaction support for atomic operations.

  5. History Tracking: For GenericEntityRepository, maintains a history of changes to records.

Key Components

  1. CloverRepository: The main implementation of GenericRepository that handles CRUD operations and queries.

  2. CloverEntityRepository: The implementation of GenericEntityRepository for single-record repositories.

  3. 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