db
Last updated: 2025-06-26 01:05:00.306115 File source: link on GitLab
db
Table of Contents
Specification
Description
This package defines the local database functionality for the Device Management Service (DMS). It provides a generic repository pattern for database operations with a clover
implementation, which is a NoSQL
or document oriented database implementation.
The package uses generic interfaces to support different data types and provides query condition functions for building database queries.
Structure and Organisation
Here is quick overview of the contents of this pacakge:
README: Current file which is aimed towards developers who wish to use and modify the package functionality.
repositories: This folder contains the core interfaces and implementations for database operations.
generic_repository.go: Defines the
GenericRepository
interface with basic CRUD operations and standard querying methods using generic types.generic_entity_repository.go: Defines the
GenericEntityRepository
interface for repositories handling a single record.conditions.go: Contains query condition functions (EQ, GT, GTE, LT, LTE, IN, LIKE) for building database queries.
conditions_test.go: Contains unit tests for the query condition functions.
utils.go: Contains utility functions for database operations.
utils_test.go: Contains unit tests for the utility functions.
errors.go: Defines error types for database operations.
clover: Contains the CloverDB (NoSQL) implementation of the repository interfaces.
generic_repository.go: Implements the
GenericRepository
interface for CloverDB.generic_entity_repository.go: Implements the
GenericEntityRepository
interface for CloverDB.clover.go: Contains the CloverDB connection and initialization logic.
Various test files for ensuring functionality works as expected.
specs: This folder contains the class diagram of the package.
Class Diagram
The class diagram for the db
package is shown below.
Source file
Rendered from source file
!$rootUrlGitlab = "https://gitlab.com/nunet/device-management-service/-/raw/main"
!$packageRelativePath = "/db"
!$packageUrlGitlab = $rootUrlGitlab + $packageRelativePath
!include $packageUrlGitlab/specs/class_diagram.puml
Package Specification
Refer to the README file defined in the repositories folder for detailed specification of the package.
Key Interfaces
GenericRepository: Defines basic CRUD operations (Create, Read, Update, Delete) and standard querying methods using generic types, allowing it to be used with any data type.
GenericEntityRepository: Defines operations for repositories handling a single record, with methods for saving, retrieving, clearing, and tracking history.
Query Conditions
The package provides functions to create query conditions for database operations:
EQ
: Creates equality comparison (field = value)GT
: Creates greater-than comparison (field > value)GTE
: Creates greater-than-or-equal comparison (field >= value)LT
: Creates less-than comparison (field < value)LTE
: Creates less-than-or-equal comparison (field <= value)IN
: Creates IN comparison (field IN values)LIKE
: Creates LIKE comparison for pattern matching (field LIKE pattern)
Last updated