LogoLogo
WebsiteTechnical Discussions
Developer documentation
Developer documentation
  • Public Technical Documentation
    • device-management-service
      • main
        • actor
        • api
        • cmd
          • actor
          • cap
        • db
          • repositories
            • clover
        • dms
          • behaviors
          • jobs
          • node
          • onboarding
          • resources
        • docs
          • deployments
          • onboarding
          • private_network
        • executor
          • docker
          • firecracker
          • background_tasks
          • config
          • hardware
        • maint-scripts
        • network
          • libp2p
        • observability
        • specs
          • basic_controller
          • s3
          • volume
          • integration
        • tokenomics
        • types
        • utils
          • validate
      • release
        • actor
        • api
        • cmd
          • actor
          • cap
        • db
          • repositories
            • clover
        • dms
          • behaviors
          • hardware
          • jobs
          • node
          • onboarding
          • resources
        • docs
          • deployments
          • onboarding
          • private_network
        • executor
          • docker
          • firecracker
        • internal
          • background_tasks
          • config
        • maint-scripts
        • network
          • libp2p
        • observability
        • plugins
        • specs
        • storage
          • basic_controller
          • s3
          • volume
        • test
        • tokenomics
        • types
        • utils
          • validate
    • solutions
      • asi-node
        • main
          • demos
            • ocap_auth
              • ansible
              • videos
          • did-auth-use-scenarios
            • create-a-hosting-deployment
            • make-a-payment
            • manage-dids-and-ocaps
            • register-an-ai-agent
            • submit-a-compute-job
          • pilots
            • asi-create-authentication-poc
        • release
      • nunet-appliance
        • main
        • release
    • test-suite
      • main
        • cicd
          • tests
            • feature_environment
          • cli
          • dms-on-lxd
            • local
        • environments
          • development
          • feature
          • production
          • staging
        • infrastructure
          • cloud-init
          • dms-on-lxd
          • nginx
        • lib
        • stages
          • dependency_scanning
          • functional_tests
          • integration_tests
          • load_tests
          • regression_tests
          • security_tests_1
          • security_tests_2
          • security_tests_live
          • unit_tests
          • user_acceptance_tests
      • release
        • cicd
          • tests
            • feature_environment
          • cli
          • dms-on-lxd
            • local
        • environments
          • development
          • feature
          • production
          • staging
        • infrastructure
          • cloud-init
          • dms-on-lxd
          • nginx
        • lib
        • stages
          • dependency_scanning
          • functional_tests
          • integration_tests
          • load_tests
          • regression_tests
          • security_tests_1
          • security_tests_2
          • security_tests_live
          • unit_tests
          • user_acceptance_tests
    • team-processes-and-guidelines
      • main
        • best_practices
        • ci_cd_pipeline
        • community_feedback_process
        • contributing_guidelines
        • git_workflows
        • nunet_test_process_and_environments
        • secure_coding_guidelines
        • specification_and_documentation
        • team_process
          • a_project_management
          • b_ceremonies_artifacts
          • c_drum_buffer_rope
          • d_development_process
          • e_culture_rules
          • f_mr_review
        • vulnerability_management
          • devsecops_maturity_models
          • nunet_security_pipeline
          • secret_management
          • sop_security_mr_review
Powered by GitBook
On this page
  • clover
  • Table of Contents
  • Specification
Export as PDF
  1. Public Technical Documentation
  2. device-management-service
  3. release
  4. db
  5. repositories

clover

PreviousrepositoriesNextdms

Last updated 11 hours ago

Last updated: 2025-05-15 01:08:28.173182 File source:

clover

Table of Contents

Specification

Description

This sub package contains CloverDB implementation of the database interfaces.

Structure and Organisation

Here is quick overview of the contents of this pacakge:

All files with *_test.go naming convention contain unit tests with respect to the specific implementation.

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/repositories/clover"
!$packageUrlGitlab = $rootUrlGitlab + $packageRelativePath
 
!include $packageUrlGitlab/specs/class_diagram.puml

Functionality

GenericRepository

NewGenericRepository

  • signature: NewGenericRepository[T repositories.ModelType](db *clover.DB) -> repositories.GenericRepository[T]

  • input: clover Database object

  • output: Repository of type db.clover.GenericRepositoryclover

NewGenericRepository function creates a new instance of GenericRepositoryclover struct. It initializes and returns a repository with the provided clover database.

Interface Methods

query

  • signature: query(includeDeleted bool) -> *clover_q.Query

  • input: boolean value to choose whether to include deleted records

queryWithID

  • signature: queryWithID(id interface{}, includeDeleted bool) -> *clover_q.Query

  • input #1: identifier

  • input #2: boolean value to choose whether to include deleted records

Providing includeDeleted as False will add a condition to exclude the deleted records.

GenericEntityRepository

NewGenericEntityRepository

  • signature: NewGenericEntityRepository[T repositories.ModelType](db *clover.DB) repositories.GenericEntityRepository[T]

  • input: clover Database object

  • output: Repository of type db.clover.GenericEntityRepositoryclover

NewGenericEntityRepository creates a new instance of GenericEntityRepositoryclover struct. It initializes and returns a repository with the provided clover database instance and name of the collection in the database.

Interface Methods

query

  • signature: query() -> *clover_q.Query

  • input: None

Data Types

  • db.clover.GenericRepositoryClover: This is a generic repository implementation using clover as an ORM

type GenericRepositoryClover[T repositories.ModelType] struct {
	db         *clover.DB // db is the Clover database instance.
	collection string     // collection is the name of the collection in the database.
}
  • db.clover.GenericEntityRepositoryClover: This is a generic single entity repository implementation using clover as an ORM

type GenericEntityRepositoryClover[T repositories.ModelType] struct {
	db         *clover.DB // db is the Clover database instance.
	collection string     // collection is the name of the collection in the database.
}

For other data types refer to db package readme.

Testing

Refer to *_test.go files for unit tests of different functionalities.

Proposed Functionality / Requirements

List of issues

All issues that are related to the implementation of db package can be found below. These include any proposals for modifications to the package or new functionality needed to cover the requirements of other packages.

References

: Current file which is aimed towards developers who wish to use and modify the database functionality.

: This file implements the methods of GenericRepository interface.

: This file implements the methods of GenericEntityRepository interface.

: This file contains implementation of DeploymentRequestFlat interface.

: This file contains implementation of RequestTracker interface.

: This file contains implementation of VirtualMachine interface.

: This file contains implementation of interfaces defined in .

: This file contains utility functions with respect to clover implementation.

See db package for methods of GenericRepository interface

output:

query function creates and returns a new CloverDB object. Input value of False will add a condition to exclude the deleted records.

output:

queryWithID function creates and returns a new CloverDB object. The provided inputs are added to query conditions. The identifier will be compared to primary key field value of the repository.

See db package for methods of GenericEntityRepository interface.

output:

query function creates and returns a new CloverDB object.

README
generic_repository
generic_entity_repository
deployment
elk_stats
firecracker
machine
machine.go
utils
clover Class diagram
readme
CloverDB query object
Query
CloverDB query object
Query
readme
CloverDB query object
Query
db package implementation
link on GitLab
Project README
Release/Build Status
Changelog
License
Contribution Guidelines
Code of Conduct
Secure Coding Guidelines
Description
Structure and Organisation
Class Diagram
Functionality
Data Types
Testing
Proposed Functionality/Requirements
References