mongo

package
v0.2.5 Latest Latest
Warning

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

Go to latest
Published: Feb 10, 2025 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const FetchSyncJobsDefaultBatchSize = 1000
View Source
const SyncDeleteBson = "sync_delete"
View Source
const SyncTodoBson = "sync_todo"
View Source
const SyncUnixTimestampBson = "sync_unix_timestamp"

Variables

View Source
var AspectBson = getBsonFieldObject[models.Aspect]()
View Source
var AspectNodeBson = getBsonFieldObject[models.AspectNode]()
View Source
var CharacteristicBson = getBsonFieldObject[models.Characteristic]()
View Source
var ConceptBson = getBsonFieldObject[models.Concept]()
View Source
var CreateCollections = []func(db *Mongo) error{}
View Source
var DeviceBson = getBsonFieldObject[model.DeviceWithConnectionState]()
View Source
var DeviceClassBson = getBsonFieldObject[models.DeviceClass]()
View Source
var DeviceGroupBson = getBsonFieldObject[models.DeviceGroup]()
View Source
var DeviceTypeBson = getBsonFieldObject[models.DeviceType]()
View Source
var DeviceTypeCriteriaBson = getBsonFieldObject[model.DeviceTypeCriteria]()
View Source
var FunctionBson = getBsonFieldObject[models.Function]()
View Source
var HubBson = getBsonFieldObject[model.HubWithConnectionState]()
View Source
var LocationBson = getBsonFieldObject[models.Location]()
View Source
var NotDeletedFilterKey = "$or"
View Source
var NotDeletedFilterValue = []interface{}{
	bson.M{SyncDeleteBson: bson.M{"$exists": false}},
	bson.M{SyncDeleteBson: false},
}
View Source
var ProtocolBson = getBsonFieldObject[models.Protocol]()

Functions

func FetchSyncJobs added in v0.1.53

func FetchSyncJobs[OutputType any](collection *mongo.Collection, syncLockDuration time.Duration, maxBatchSize int) (jobs []OutputType, err error)

Types

type AspectWithSyncInfo added in v0.1.53

type AspectWithSyncInfo struct {
	models.Aspect `bson:",inline"`
	SyncInfo      `bson:",inline"`
}

type CharacteristicWithSyncInfo added in v0.1.53

type CharacteristicWithSyncInfo struct {
	models.Characteristic `bson:",inline"`
	SyncInfo              `bson:",inline"`
}

type ConceptWithSyncInfo added in v0.1.53

type ConceptWithSyncInfo struct {
	models.Concept `bson:",inline"`
	SyncInfo       `bson:",inline"`
}

type DeviceClassWithSyncInfo added in v0.1.53

type DeviceClassWithSyncInfo struct {
	models.DeviceClass `bson:",inline"`
	SyncInfo           `bson:",inline"`
}

type DeviceGroupWithSyncInfo added in v0.1.53

type DeviceGroupWithSyncInfo struct {
	models.DeviceGroup `bson:",inline"`
	SyncInfo           `bson:",inline"`
	SyncUser           string `bson:"sync_user"`
}

type DeviceTypeWithSyncInfo added in v0.1.53

type DeviceTypeWithSyncInfo struct {
	models.DeviceType `bson:",inline"`
	SyncInfo          `bson:",inline"`
}

type DeviceWithSyncInfo added in v0.1.53

type DeviceWithSyncInfo struct {
	model.DeviceWithConnectionState `bson:",inline"`
	SyncInfo                        `bson:",inline"`
}

type FunctionWithSyncInfo added in v0.1.53

type FunctionWithSyncInfo struct {
	models.Function `bson:",inline"`
	SyncInfo        `bson:",inline"`
}

type GeneratedDeviceGroupMigrationMethods added in v0.1.20

type GeneratedDeviceGroupMigrationMethods interface {
	DeviceIdToGeneratedDeviceGroupId(deviceId string) string
	EnsureGeneratedDeviceGroup(device models.Device) (err error)
}

type HubWithSyncInfo added in v0.1.53

type HubWithSyncInfo struct {
	model.HubWithConnectionState `bson:",inline"`
	SyncInfo                     `bson:",inline"`
}

type LocationWithSyncInfo added in v0.1.53

type LocationWithSyncInfo struct {
	models.Location `bson:",inline"`
	SyncInfo        `bson:",inline"`
	SyncUser        string `bson:"sync_user"`
}

type Mongo

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

func New

func New(conf configuration.Config) (*Mongo, error)

func (*Mongo) AspectIsUsed

func (this *Mongo) AspectIsUsed(ctx context.Context, id string) (result bool, where []string, err error)

func (*Mongo) CharacteristicIsUsed

func (this *Mongo) CharacteristicIsUsed(ctx context.Context, id string) (result bool, where []string, err error)

func (*Mongo) CharacteristicIsUsedWithConceptInDeviceType

func (this *Mongo) CharacteristicIsUsedWithConceptInDeviceType(ctx context.Context, characteristicId string, conceptId string) (result bool, where []string, err error)

func (*Mongo) ConceptIsUsed

func (this *Mongo) ConceptIsUsed(ctx context.Context, id string) (result bool, where []string, err error)

func (*Mongo) CreateId

func (this *Mongo) CreateId() string

func (*Mongo) DeviceClassIsUsed

func (this *Mongo) DeviceClassIsUsed(ctx context.Context, id string) (result bool, where []string, err error)

func (*Mongo) DeviceLocalIdsToIds added in v0.1.24

func (this *Mongo) DeviceLocalIdsToIds(ctx context.Context, owner string, localIds []string) (ids []string, err error)

func (*Mongo) Disconnect

func (this *Mongo) Disconnect()

func (*Mongo) FunctionIsUsed

func (this *Mongo) FunctionIsUsed(ctx context.Context, id string) (result bool, where []string, err error)

func (*Mongo) GetAspect

func (this *Mongo) GetAspect(ctx context.Context, id string) (aspect models.Aspect, exists bool, err error)

func (*Mongo) GetAspectNode

func (this *Mongo) GetAspectNode(ctx context.Context, id string) (aspectNode models.AspectNode, exists bool, err error)

func (*Mongo) GetCharacteristic

func (this *Mongo) GetCharacteristic(ctx context.Context, id string) (characteristic models.Characteristic, exists bool, err error)

func (*Mongo) GetConceptWithCharacteristics

func (this *Mongo) GetConceptWithCharacteristics(ctx context.Context, id string) (concept models.ConceptWithCharacteristics, exists bool, err error)

func (*Mongo) GetConceptWithoutCharacteristics

func (this *Mongo) GetConceptWithoutCharacteristics(ctx context.Context, id string) (concept models.Concept, exists bool, err error)

func (*Mongo) GetConfigurableCandidates

func (this *Mongo) GetConfigurableCandidates(ctx context.Context, serviceId string) (result []model.DeviceTypeCriteria, err error)

func (*Mongo) GetDevice

func (this *Mongo) GetDevice(ctx context.Context, id string) (device model.DeviceWithConnectionState, exists bool, err error)

func (*Mongo) GetDeviceByLocalId

func (this *Mongo) GetDeviceByLocalId(ctx context.Context, ownerId string, localId string) (device model.DeviceWithConnectionState, exists bool, err error)

func (*Mongo) GetDeviceClass

func (this *Mongo) GetDeviceClass(ctx context.Context, id string) (deviceClass models.DeviceClass, exists bool, err error)

func (*Mongo) GetDeviceGroup

func (this *Mongo) GetDeviceGroup(ctx context.Context, id string) (deviceGroup models.DeviceGroup, exists bool, err error)

func (*Mongo) GetDeviceType

func (this *Mongo) GetDeviceType(ctx context.Context, id string) (deviceType models.DeviceType, exists bool, err error)

func (*Mongo) GetDeviceTypeCriteriaByAspectIds added in v0.0.6

func (this *Mongo) GetDeviceTypeCriteriaByAspectIds(ctx context.Context, ids []string, includeModified bool) (result []model.DeviceTypeCriteria, err error)

func (*Mongo) GetDeviceTypeCriteriaByCharacteristicIds added in v0.0.6

func (this *Mongo) GetDeviceTypeCriteriaByCharacteristicIds(ctx context.Context, ids []string, includeModified bool) (result []model.DeviceTypeCriteria, err error)

func (*Mongo) GetDeviceTypeCriteriaByDeviceClassIds added in v0.0.6

func (this *Mongo) GetDeviceTypeCriteriaByDeviceClassIds(ctx context.Context, ids []string, includeModified bool) (result []model.DeviceTypeCriteria, err error)

func (*Mongo) GetDeviceTypeCriteriaByFunctionIds added in v0.0.6

func (this *Mongo) GetDeviceTypeCriteriaByFunctionIds(ctx context.Context, ids []string, includeModified bool) (result []model.DeviceTypeCriteria, err error)

func (*Mongo) GetDeviceTypeCriteriaForDeviceTypeIdsAndFilterCriteria

func (this *Mongo) GetDeviceTypeCriteriaForDeviceTypeIdsAndFilterCriteria(ctx context.Context, deviceTypeIds []interface{}, criteria model.FilterCriteria, includeModified bool) (result []model.DeviceTypeCriteria, err error)

func (*Mongo) GetDeviceTypeIdsByFilterCriteria

func (this *Mongo) GetDeviceTypeIdsByFilterCriteria(ctx context.Context, criteria []model.FilterCriteria, interactionsFilter []string, includeModified bool) (result []interface{}, err error)

all criteria must match; if interactionsFilter is used (len > 0), at least one must match

func (*Mongo) GetDeviceTypeIdsByFilterCriteriaV2

func (this *Mongo) GetDeviceTypeIdsByFilterCriteriaV2(ctx context.Context, criteria []model.FilterCriteria, includeModified bool) (result []interface{}, err error)

func (*Mongo) GetDeviceTypesByServiceId

func (this *Mongo) GetDeviceTypesByServiceId(ctx context.Context, serviceId string) (result []models.DeviceType, err error)

func (*Mongo) GetFunction

func (this *Mongo) GetFunction(ctx context.Context, id string) (function models.Function, exists bool, err error)

func (*Mongo) GetHub

func (this *Mongo) GetHub(ctx context.Context, id string) (hub model.HubWithConnectionState, exists bool, err error)

func (*Mongo) GetHubsByDeviceId added in v0.0.20

func (this *Mongo) GetHubsByDeviceId(ctx context.Context, id string) (hubs []model.HubWithConnectionState, err error)

func (*Mongo) GetLocation

func (this *Mongo) GetLocation(ctx context.Context, id string) (location models.Location, exists bool, err error)

func (*Mongo) GetProtocol

func (this *Mongo) GetProtocol(ctx context.Context, id string) (protocol models.Protocol, exists bool, err error)

func (*Mongo) ListAllAspectNodes

func (this *Mongo) ListAllAspectNodes(ctx context.Context) (result []models.AspectNode, err error)

func (*Mongo) ListAllAspects

func (this *Mongo) ListAllAspects(ctx context.Context) (result []models.Aspect, err error)

func (*Mongo) ListAllCharacteristics

func (this *Mongo) ListAllCharacteristics(ctx context.Context) (result []models.Characteristic, err error)

func (*Mongo) ListAllControllingFunctionsByDeviceClass

func (this *Mongo) ListAllControllingFunctionsByDeviceClass(ctx context.Context, class string) (result []models.Function, err error)

func (*Mongo) ListAllDeviceClasses

func (this *Mongo) ListAllDeviceClasses(ctx context.Context) (result []models.DeviceClass, err error)

func (*Mongo) ListAllDeviceClassesUsedWithControllingFunctions

func (this *Mongo) ListAllDeviceClassesUsedWithControllingFunctions(ctx context.Context) (result []models.DeviceClass, err error)

func (*Mongo) ListAllFunctionsByDeviceClass

func (this *Mongo) ListAllFunctionsByDeviceClass(ctx context.Context, class string) (result []models.Function, err error)

func (*Mongo) ListAllFunctionsByType

func (this *Mongo) ListAllFunctionsByType(ctx context.Context, rdfType string) (result []models.Function, err error)

func (*Mongo) ListAllMeasuringFunctionsByAspect

func (this *Mongo) ListAllMeasuringFunctionsByAspect(ctx context.Context, aspect string, ancestors bool, descendants bool) (result []models.Function, err error)

returns all measuring functions used in combination with given aspect (and optional its descendants and ancestors)

func (*Mongo) ListAspectNodes added in v0.1.40

func (this *Mongo) ListAspectNodes(ctx context.Context, listOptions model.AspectListOptions) (result []models.AspectNode, total int64, err error)

func (*Mongo) ListAspectNodesByIdList

func (this *Mongo) ListAspectNodesByIdList(ctx context.Context, ids []string) (result []models.AspectNode, err error)

func (*Mongo) ListAspectNodesWithMeasuringFunction

func (this *Mongo) ListAspectNodesWithMeasuringFunction(ctx context.Context, ancestors bool, descendants bool) (result []models.AspectNode, err error)

returns all aspects used in combination with measuring functions (usage may optionally be by its descendants or ancestors)

func (*Mongo) ListAspects added in v0.1.40

func (this *Mongo) ListAspects(ctx context.Context, listOptions model.AspectListOptions) (result []models.Aspect, total int64, err error)

func (*Mongo) ListAspectsWithMeasuringFunction

func (this *Mongo) ListAspectsWithMeasuringFunction(ctx context.Context, ancestors bool, descendants bool) (result []models.Aspect, err error)

returns all aspects used in combination with measuring functions (usage may optionally be by its descendants or ancestors)

func (*Mongo) ListCharacteristics added in v0.1.48

func (this *Mongo) ListCharacteristics(ctx context.Context, listOptions model.CharacteristicListOptions) (result []models.Characteristic, total int64, err error)

func (*Mongo) ListConcepts added in v0.1.41

func (this *Mongo) ListConcepts(ctx context.Context, listOptions model.ConceptListOptions) (result []models.Concept, total int64, err error)

func (*Mongo) ListConceptsWithCharacteristics added in v0.1.41

func (this *Mongo) ListConceptsWithCharacteristics(ctx context.Context, listOptions model.ConceptListOptions) (result []models.ConceptWithCharacteristics, total int64, err error)

func (*Mongo) ListDeviceClasses added in v0.1.43

func (this *Mongo) ListDeviceClasses(ctx context.Context, listOptions model.DeviceClassListOptions) (result []models.DeviceClass, total int64, err error)

func (*Mongo) ListDeviceGroups

func (this *Mongo) ListDeviceGroups(ctx context.Context, listOptions model.DeviceGroupListOptions) (result []models.DeviceGroup, total int64, err error)

func (*Mongo) ListDeviceTypes

func (this *Mongo) ListDeviceTypes(ctx context.Context, limit int64, offset int64, sort string, filterCriteria []model.FilterCriteria, interactionsFilter []string, includeModified bool) (result []models.DeviceType, err error)

func (*Mongo) ListDeviceTypesV2

func (this *Mongo) ListDeviceTypesV2(ctx context.Context, limit int64, offset int64, sort string, filterCriteria []model.FilterCriteria, includeModified bool) (result []models.DeviceType, err error)

func (*Mongo) ListDeviceTypesV3 added in v0.1.12

func (this *Mongo) ListDeviceTypesV3(ctx context.Context, listOptions model.DeviceTypeListOptions) (result []models.DeviceType, total int64, err error)

func (*Mongo) ListDevices added in v0.1.0

func (this *Mongo) ListDevices(ctx context.Context, listOptions model.DeviceListOptions, withTotal bool) (result []model.DeviceWithConnectionState, total int64, err error)

func (*Mongo) ListFunctions added in v0.1.38

func (this *Mongo) ListFunctions(ctx context.Context, listOptions model.FunctionListOptions) (result []models.Function, total int64, err error)

func (*Mongo) ListHubs added in v0.1.0

func (this *Mongo) ListHubs(ctx context.Context, listOptions model.HubListOptions, withTotal bool) (result []model.HubWithConnectionState, total int64, err error)

func (*Mongo) ListLocations added in v0.1.30

func (this *Mongo) ListLocations(ctx context.Context, listOptions model.LocationListOptions) (result []models.Location, total int64, err error)

func (*Mongo) ListProtocols

func (this *Mongo) ListProtocols(ctx context.Context, limit int64, offset int64, sort string) (result []models.Protocol, err error)

func (*Mongo) RemoveAspect

func (this *Mongo) RemoveAspect(ctx context.Context, id string, syncDeleteHandler func(models.Aspect) error) error

func (*Mongo) RemoveAspectNodesByRootId

func (this *Mongo) RemoveAspectNodesByRootId(ctx context.Context, id string) error

func (*Mongo) RemoveCharacteristic

func (this *Mongo) RemoveCharacteristic(ctx context.Context, id string, syncDeleteHandler func(models.Characteristic) error) error

func (*Mongo) RemoveConcept

func (this *Mongo) RemoveConcept(ctx context.Context, id string, syncDeleteHandler func(models.Concept) error) error

func (*Mongo) RemoveDevice

func (this *Mongo) RemoveDevice(ctx context.Context, id string, syncDeleteHandler func(model.DeviceWithConnectionState) error) (err error)

func (*Mongo) RemoveDeviceClass

func (this *Mongo) RemoveDeviceClass(ctx context.Context, id string, syncDeleteHandler func(models.DeviceClass) error) error

func (*Mongo) RemoveDeviceGroup

func (this *Mongo) RemoveDeviceGroup(ctx context.Context, id string, syncDeleteHandler func(models.DeviceGroup) error) error

func (*Mongo) RemoveDeviceType

func (this *Mongo) RemoveDeviceType(ctx context.Context, id string, syncDeleteHandler func(models.DeviceType) error) error

func (*Mongo) RemoveFunction

func (this *Mongo) RemoveFunction(ctx context.Context, id string, syncDeleteHandler func(models.Function) error) error

func (*Mongo) RemoveHub

func (this *Mongo) RemoveHub(ctx context.Context, id string, syncDeleteHandler func(model.HubWithConnectionState) error) error

func (*Mongo) RemoveLocation

func (this *Mongo) RemoveLocation(ctx context.Context, id string, syncDeleteHandler func(models.Location) error) error

func (*Mongo) RemoveProtocol

func (this *Mongo) RemoveProtocol(ctx context.Context, id string, syncDeleteHandler func(models.Protocol) error) error

func (*Mongo) RetryAspectSync added in v0.1.53

func (this *Mongo) RetryAspectSync(lockduration time.Duration, syncDeleteHandler func(models.Aspect) error, syncHandler func(models.Aspect) error) error

func (*Mongo) RetryCharacteristicSync added in v0.1.53

func (this *Mongo) RetryCharacteristicSync(lockduration time.Duration, syncDeleteHandler func(models.Characteristic) error, syncHandler func(models.Characteristic) error) error

func (*Mongo) RetryConceptSync added in v0.1.53

func (this *Mongo) RetryConceptSync(lockduration time.Duration, syncDeleteHandler func(models.Concept) error, syncHandler func(models.Concept) error) error

func (*Mongo) RetryDeviceClassSync added in v0.1.53

func (this *Mongo) RetryDeviceClassSync(lockduration time.Duration, syncDeleteHandler func(models.DeviceClass) error, syncHandler func(models.DeviceClass) error) error

func (*Mongo) RetryDeviceGroupSync added in v0.1.53

func (this *Mongo) RetryDeviceGroupSync(lockduration time.Duration, syncDeleteHandler func(models.DeviceGroup) error, syncHandler func(dg models.DeviceGroup, user string) error) error

func (*Mongo) RetryDeviceSync added in v0.1.53

func (this *Mongo) RetryDeviceSync(lockduration time.Duration, syncDeleteHandler func(model.DeviceWithConnectionState) error, syncHandler func(model.DeviceWithConnectionState) error) error

func (*Mongo) RetryDeviceTypeSync added in v0.1.53

func (this *Mongo) RetryDeviceTypeSync(lockduration time.Duration, syncDeleteHandler func(models.DeviceType) error, syncHandler func(models.DeviceType) error) error

func (*Mongo) RetryFunctionSync added in v0.1.53

func (this *Mongo) RetryFunctionSync(lockduration time.Duration, syncDeleteHandler func(models.Function) error, syncHandler func(models.Function) error) error

func (*Mongo) RetryHubSync added in v0.1.53

func (this *Mongo) RetryHubSync(lockduration time.Duration, syncDeleteHandler func(model.HubWithConnectionState) error, syncHandler func(model.HubWithConnectionState) error) error

func (*Mongo) RetryLocationSync added in v0.1.53

func (this *Mongo) RetryLocationSync(lockduration time.Duration, syncDeleteHandler func(models.Location) error, syncHandler func(l models.Location, user string) error) error

func (*Mongo) RetryProtocolSync added in v0.1.53

func (this *Mongo) RetryProtocolSync(lockduration time.Duration, syncDeleteHandler func(models.Protocol) error, syncHandler func(models.Protocol) error) error

func (*Mongo) RunStartupMigrations added in v0.0.15

func (this *Mongo) RunStartupMigrations(helper GeneratedDeviceGroupMigrationMethods) error

func (*Mongo) SetAspect

func (this *Mongo) SetAspect(ctx context.Context, aspect models.Aspect, syncHandler func(models.Aspect) error) (err error)

func (*Mongo) SetAspectNode

func (this *Mongo) SetAspectNode(ctx context.Context, aspectNode models.AspectNode) error

func (*Mongo) SetCharacteristic

func (this *Mongo) SetCharacteristic(ctx context.Context, characteristic models.Characteristic, syncHandler func(models.Characteristic) error) error

func (*Mongo) SetConcept

func (this *Mongo) SetConcept(ctx context.Context, concept models.Concept, syncHandler func(models.Concept) error) error

func (*Mongo) SetDevice

func (this *Mongo) SetDevice(ctx context.Context, device model.DeviceWithConnectionState, syncHandler func(model.DeviceWithConnectionState) error) error

func (*Mongo) SetDeviceClass

func (this *Mongo) SetDeviceClass(ctx context.Context, deviceClass models.DeviceClass, syncHandler func(models.DeviceClass) error) error

func (*Mongo) SetDeviceConnectionState added in v0.1.0

func (this *Mongo) SetDeviceConnectionState(ctx context.Context, id string, state models.ConnectionState) error

func (*Mongo) SetDeviceGroup

func (this *Mongo) SetDeviceGroup(ctx context.Context, deviceGroup models.DeviceGroup, syncHandler func(dg models.DeviceGroup, user string) error, user string) error

func (*Mongo) SetDeviceType

func (this *Mongo) SetDeviceType(ctx context.Context, deviceType models.DeviceType, syncHandler func(models.DeviceType) error) error

func (*Mongo) SetFunction

func (this *Mongo) SetFunction(ctx context.Context, function models.Function, syncHandler func(models.Function) error) (err error)

func (*Mongo) SetHub

func (this *Mongo) SetHub(ctx context.Context, hub model.HubWithConnectionState, syncHandler func(model.HubWithConnectionState) error) (err error)

func (*Mongo) SetHubConnectionState added in v0.1.0

func (this *Mongo) SetHubConnectionState(ctx context.Context, id string, state models.ConnectionState) error

func (*Mongo) SetLocation

func (this *Mongo) SetLocation(ctx context.Context, location models.Location, syncHandler func(l models.Location, user string) error, user string) (err error)

func (*Mongo) SetProtocol

func (this *Mongo) SetProtocol(ctx context.Context, protocol models.Protocol, syncHandler func(models.Protocol) error) (err error)

type ProtocolWithSyncInfo added in v0.1.53

type ProtocolWithSyncInfo struct {
	models.Protocol `bson:",inline"`
	SyncInfo        `bson:",inline"`
}

type SyncInfo added in v0.1.53

type SyncInfo struct {
	SyncTodo          bool  `bson:"sync_todo"`
	SyncDelete        bool  `bson:"sync_delete"`
	SyncUnixTimestamp int64 `bson:"sync_unix_timestamp"`
}

Jump to

Keyboard shortcuts

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