mongo

package
v1.36.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 18, 2026 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Overview

Package mongo implements every *.Repository interface against MongoDB. Entities carry explicit `bson:"<lowercase>"` tags; constants in fields.go mirror them. Unique indexes here stand in for the SQL UNIQUE constraints. Errors are reused from `repoerrors` so use cases' `errors.As` checks work.

Index

Constants

View Source
const (
	CollectionDevices            = "devices"
	CollectionProfiles           = "profiles"
	CollectionCIRAConfigs        = "ciraconfigs"
	CollectionDomains            = "domains"
	CollectionIEEE8021xConfigs   = "ieee8021xconfigs"
	CollectionWirelessConfigs    = "wirelessconfigs"
	CollectionProfileWiFiConfigs = "profiles_wirelessconfigs"
)
View Source
const DatabaseName = "consoledb"
View Source
const DefaultTop = 100

DefaultTop is the page size used when a caller passes top<=0 (mirrors sqldb).

Variables

This section is empty.

Functions

func Connect

func Connect(ctx context.Context, uri string, log logger.Interface) (*mongo.Client, *mongo.Database, error)

Connect dials Mongo, pings, and creates the unique indexes that stand in for the SQL UNIQUE constraints. Caller disconnects the returned client.

Types

type CIRARepo

type CIRARepo struct {
	// contains filtered or unexported fields
}

func NewCIRARepo

func NewCIRARepo(db *mongo.Database) *CIRARepo

func (*CIRARepo) Delete

func (r *CIRARepo) Delete(ctx context.Context, configName, tenantID string) (bool, error)

func (*CIRARepo) Get

func (r *CIRARepo) Get(ctx context.Context, top, skip int, tenantID string) ([]entity.CIRAConfig, error)

func (*CIRARepo) GetByName

func (r *CIRARepo) GetByName(ctx context.Context, configName, tenantID string) (*entity.CIRAConfig, error)

func (*CIRARepo) GetCount

func (r *CIRARepo) GetCount(ctx context.Context, tenantID string) (int, error)

func (*CIRARepo) Insert

func (r *CIRARepo) Insert(ctx context.Context, c *entity.CIRAConfig) (string, error)

func (*CIRARepo) Update

func (r *CIRARepo) Update(ctx context.Context, c *entity.CIRAConfig) (bool, error)

type DeviceRepo

type DeviceRepo struct {
	// contains filtered or unexported fields
}

func NewDeviceRepo

func NewDeviceRepo(db *mongo.Database) *DeviceRepo

func (*DeviceRepo) Delete

func (r *DeviceRepo) Delete(ctx context.Context, guid, tenantID string) (bool, error)

func (*DeviceRepo) Get

func (r *DeviceRepo) Get(ctx context.Context, top, skip int, tenantID string) ([]entity.Device, error)

func (*DeviceRepo) GetByColumn

func (r *DeviceRepo) GetByColumn(ctx context.Context, columnName, queryValue, tenantID string) ([]entity.Device, error)

func (*DeviceRepo) GetByID

func (r *DeviceRepo) GetByID(ctx context.Context, guid, tenantID string) (*entity.Device, error)

func (*DeviceRepo) GetByTags

func (r *DeviceRepo) GetByTags(ctx context.Context, tags []string, method string, limit, offset int, tenantID string) ([]entity.Device, error)

func (*DeviceRepo) GetCount

func (r *DeviceRepo) GetCount(ctx context.Context, tenantID string) (int, error)

func (*DeviceRepo) GetDistinctTags

func (r *DeviceRepo) GetDistinctTags(ctx context.Context, tenantID string) ([]string, error)

func (*DeviceRepo) Insert

func (r *DeviceRepo) Insert(ctx context.Context, d *entity.Device) (string, error)

func (*DeviceRepo) Update

func (r *DeviceRepo) Update(ctx context.Context, d *entity.Device) (bool, error)

func (*DeviceRepo) UpdateConnectionStatus

func (r *DeviceRepo) UpdateConnectionStatus(ctx context.Context, guid string, status bool) error

func (*DeviceRepo) UpdateLastSeen

func (r *DeviceRepo) UpdateLastSeen(ctx context.Context, guid string) error

type DomainRepo

type DomainRepo struct {
	// contains filtered or unexported fields
}

func NewDomainRepo

func NewDomainRepo(db *mongo.Database) *DomainRepo

func (*DomainRepo) Delete

func (r *DomainRepo) Delete(ctx context.Context, name, tenantID string) (bool, error)

func (*DomainRepo) Get

func (r *DomainRepo) Get(ctx context.Context, top, skip int, tenantID string) ([]entity.Domain, error)

func (*DomainRepo) GetByName

func (r *DomainRepo) GetByName(ctx context.Context, name, tenantID string) (*entity.Domain, error)

func (*DomainRepo) GetCount

func (r *DomainRepo) GetCount(ctx context.Context, tenantID string) (int, error)

func (*DomainRepo) GetDomainByDomainSuffix

func (r *DomainRepo) GetDomainByDomainSuffix(ctx context.Context, domainSuffix, tenantID string) (*entity.Domain, error)

func (*DomainRepo) Insert

func (r *DomainRepo) Insert(ctx context.Context, d *entity.Domain) (string, error)

func (*DomainRepo) Update

func (r *DomainRepo) Update(ctx context.Context, d *entity.Domain) (bool, error)

type IEEE8021xRepo

type IEEE8021xRepo struct {
	// contains filtered or unexported fields
}

func NewIEEE8021xRepo

func NewIEEE8021xRepo(db *mongo.Database) *IEEE8021xRepo

func (*IEEE8021xRepo) CheckProfileExists

func (r *IEEE8021xRepo) CheckProfileExists(ctx context.Context, profileName, tenantID string) (bool, error)

func (*IEEE8021xRepo) Delete

func (r *IEEE8021xRepo) Delete(ctx context.Context, profileName, tenantID string) (bool, error)

func (*IEEE8021xRepo) Get

func (r *IEEE8021xRepo) Get(ctx context.Context, top, skip int, tenantID string) ([]entity.IEEE8021xConfig, error)

func (*IEEE8021xRepo) GetByName

func (r *IEEE8021xRepo) GetByName(ctx context.Context, profileName, tenantID string) (*entity.IEEE8021xConfig, error)

func (*IEEE8021xRepo) GetCount

func (r *IEEE8021xRepo) GetCount(ctx context.Context, tenantID string) (int, error)

func (*IEEE8021xRepo) Insert

func (*IEEE8021xRepo) Update

type ProfileRepo

type ProfileRepo struct {
	// contains filtered or unexported fields
}

func NewProfileRepo

func NewProfileRepo(db *mongo.Database, log logger.Interface) *ProfileRepo

func (*ProfileRepo) Delete

func (r *ProfileRepo) Delete(ctx context.Context, profileName, tenantID string) (bool, error)

func (*ProfileRepo) Get

func (r *ProfileRepo) Get(ctx context.Context, top, skip int, tenantID string) ([]entity.Profile, error)

func (*ProfileRepo) GetByName

func (r *ProfileRepo) GetByName(ctx context.Context, profileName, tenantID string) (*entity.Profile, error)

func (*ProfileRepo) GetCount

func (r *ProfileRepo) GetCount(ctx context.Context, tenantID string) (int, error)

func (*ProfileRepo) Insert

func (r *ProfileRepo) Insert(ctx context.Context, p *entity.Profile) (string, error)

func (*ProfileRepo) Update

func (r *ProfileRepo) Update(ctx context.Context, p *entity.Profile) (bool, error)

type ProfileWiFiConfigsRepo

type ProfileWiFiConfigsRepo struct {
	// contains filtered or unexported fields
}

func NewProfileWiFiConfigsRepo

func NewProfileWiFiConfigsRepo(db *mongo.Database) *ProfileWiFiConfigsRepo

func (*ProfileWiFiConfigsRepo) DeleteByProfileName

func (r *ProfileWiFiConfigsRepo) DeleteByProfileName(ctx context.Context, profileName, tenantID string) (bool, error)

func (*ProfileWiFiConfigsRepo) GetByProfileName

func (r *ProfileWiFiConfigsRepo) GetByProfileName(ctx context.Context, profileName, tenantID string) ([]entity.ProfileWiFiConfigs, error)

func (*ProfileWiFiConfigsRepo) Insert

type WirelessRepo

type WirelessRepo struct {
	// contains filtered or unexported fields
}

func NewWirelessRepo

func NewWirelessRepo(db *mongo.Database, log logger.Interface) *WirelessRepo

func (*WirelessRepo) CheckProfileExists

func (r *WirelessRepo) CheckProfileExists(ctx context.Context, profileName, tenantID string) (bool, error)

func (*WirelessRepo) Delete

func (r *WirelessRepo) Delete(ctx context.Context, profileName, tenantID string) (bool, error)

func (*WirelessRepo) Get

func (r *WirelessRepo) Get(ctx context.Context, top, skip int, tenantID string) ([]entity.WirelessConfig, error)

func (*WirelessRepo) GetByName

func (r *WirelessRepo) GetByName(ctx context.Context, profileName, tenantID string) (*entity.WirelessConfig, error)

func (*WirelessRepo) GetCount

func (r *WirelessRepo) GetCount(ctx context.Context, tenantID string) (int, error)

func (*WirelessRepo) Insert

func (*WirelessRepo) Update

func (r *WirelessRepo) Update(ctx context.Context, w *entity.WirelessConfig) (bool, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL