Documentation ¶
Index ¶
- Constants
- Variables
- func NewDataStoreMongo(config DataStoreMongoConfig) (store.DataStore, error)
- func NewDataStoreMongoWithSession(client *mongo.Client) store.DataStore
- type DataStoreMongo
- func (db *DataStoreMongo) AddDevice(ctx context.Context, dev *model.Device) error
- func (db *DataStoreMongo) DeleteDevices(ctx context.Context, ids []model.DeviceID) (*model.UpdateResult, error)
- func (db *DataStoreMongo) DeleteGroup(ctx context.Context, group model.GroupName) (chan model.DeviceID, error)
- func (db *DataStoreMongo) GetAllAttributeNames(ctx context.Context) ([]string, error)
- func (db *DataStoreMongo) GetDevice(ctx context.Context, id model.DeviceID) (*model.Device, error)
- func (db *DataStoreMongo) GetDeviceGroup(ctx context.Context, id model.DeviceID) (model.GroupName, error)
- func (db *DataStoreMongo) GetDevices(ctx context.Context, q store.ListQuery) ([]model.Device, int, error)
- func (db *DataStoreMongo) GetDevicesByGroup(ctx context.Context, group model.GroupName, skip, limit int) ([]model.DeviceID, int, error)
- func (db *DataStoreMongo) GetFiltersAttributes(ctx context.Context) ([]model.FilterAttribute, error)
- func (db *DataStoreMongo) ListGroups(ctx context.Context, filters []model.FilterPredicate) ([]model.GroupName, error)
- func (db *DataStoreMongo) Maintenance(ctx context.Context, version string, tenantIDs ...string) error
- func (db *DataStoreMongo) Migrate(ctx context.Context, version string) error
- func (db *DataStoreMongo) MigrateTenant(ctx context.Context, version string, tenantId string) error
- func (db *DataStoreMongo) Ping(ctx context.Context) error
- func (db *DataStoreMongo) SearchDevices(ctx context.Context, searchParams model.SearchParams) ([]model.Device, int, error)
- func (db *DataStoreMongo) UnsetDevicesGroup(ctx context.Context, deviceIDs []model.DeviceID, group model.GroupName) (*model.UpdateResult, error)
- func (db *DataStoreMongo) UpdateDeviceText(ctx context.Context, deviceID model.DeviceID, text string) error
- func (db *DataStoreMongo) UpdateDevicesGroup(ctx context.Context, devIDs []model.DeviceID, group model.GroupName) (*model.UpdateResult, error)
- func (db *DataStoreMongo) UpsertDevicesAttributes(ctx context.Context, ids []model.DeviceID, attrs model.DeviceAttributes) (*model.UpdateResult, error)
- func (db *DataStoreMongo) UpsertDevicesAttributesWithRevision(ctx context.Context, devices []model.DeviceUpdate, ...) (*model.UpdateResult, error)
- func (db *DataStoreMongo) UpsertDevicesAttributesWithUpdated(ctx context.Context, ids []model.DeviceID, attrs model.DeviceAttributes, ...) (*model.UpdateResult, error)
- func (db *DataStoreMongo) UpsertRemoveDeviceAttributes(ctx context.Context, id model.DeviceID, updateAttrs model.DeviceAttributes, ...) (*model.UpdateResult, error)
- func (db *DataStoreMongo) WithAutomigrate() store.DataStore
- type DataStoreMongoConfig
Constants ¶
View Source
const ( DbVersion = "1.1.0" DbName = "inventory" DbDevicesColl = "devices" DbDevId = "_id" DbDevAttributes = "attributes" DbDevGroup = "group" DbDevRevision = "revision" DbDevUpdatedTs = "updated_ts" DbDevAttributesText = "text" DbDevAttributesTs = "timestamp" DbDevAttributesDesc = "description" DbDevAttributesValue = "value" DbDevAttributesScope = "scope" DbDevAttributesName = "name" DbDevAttributesGroup = DbDevAttributes + "." + model.AttrScopeSystem + "-" + model.AttrNameGroup DbDevAttributesGroupValue = DbDevAttributesGroup + "." + DbDevAttributesValue DbScopeInventory = "inventory" FiltersAttributesMaxDevices = 5000 FiltersAttributesLimit = 500 )
Variables ¶
View Source
var (
ErrNotFound = errors.New("mongo: no documents in result")
)
Functions ¶
func NewDataStoreMongo ¶
func NewDataStoreMongo(config DataStoreMongoConfig) (store.DataStore, error)
config.ConnectionString must contain a valid
Types ¶
type DataStoreMongo ¶
type DataStoreMongo struct {
// contains filtered or unexported fields
}
func (*DataStoreMongo) DeleteDevices ¶
func (db *DataStoreMongo) DeleteDevices( ctx context.Context, ids []model.DeviceID, ) (*model.UpdateResult, error)
func (*DataStoreMongo) DeleteGroup ¶
func (*DataStoreMongo) GetAllAttributeNames ¶
func (db *DataStoreMongo) GetAllAttributeNames(ctx context.Context) ([]string, error)
func (*DataStoreMongo) GetDeviceGroup ¶
func (*DataStoreMongo) GetDevices ¶
func (*DataStoreMongo) GetDevicesByGroup ¶
func (*DataStoreMongo) GetFiltersAttributes ¶
func (db *DataStoreMongo) GetFiltersAttributes( ctx context.Context, ) ([]model.FilterAttribute, error)
func (*DataStoreMongo) ListGroups ¶
func (db *DataStoreMongo) ListGroups( ctx context.Context, filters []model.FilterPredicate, ) ([]model.GroupName, error)
func (*DataStoreMongo) Maintenance ¶
func (*DataStoreMongo) Migrate ¶
func (db *DataStoreMongo) Migrate(ctx context.Context, version string) error
func (*DataStoreMongo) MigrateTenant ¶
func (*DataStoreMongo) SearchDevices ¶
func (db *DataStoreMongo) SearchDevices( ctx context.Context, searchParams model.SearchParams, ) ([]model.Device, int, error)
func (*DataStoreMongo) UnsetDevicesGroup ¶
func (db *DataStoreMongo) UnsetDevicesGroup( ctx context.Context, deviceIDs []model.DeviceID, group model.GroupName, ) (*model.UpdateResult, error)
func (*DataStoreMongo) UpdateDeviceText ¶
func (db *DataStoreMongo) UpdateDeviceText( ctx context.Context, deviceID model.DeviceID, text string, ) error
UpdateDeviceText updates the device text field
func (*DataStoreMongo) UpdateDevicesGroup ¶
func (db *DataStoreMongo) UpdateDevicesGroup( ctx context.Context, devIDs []model.DeviceID, group model.GroupName, ) (*model.UpdateResult, error)
func (*DataStoreMongo) UpsertDevicesAttributes ¶
func (db *DataStoreMongo) UpsertDevicesAttributes( ctx context.Context, ids []model.DeviceID, attrs model.DeviceAttributes, ) (*model.UpdateResult, error)
func (*DataStoreMongo) UpsertDevicesAttributesWithRevision ¶
func (db *DataStoreMongo) UpsertDevicesAttributesWithRevision( ctx context.Context, devices []model.DeviceUpdate, attrs model.DeviceAttributes, ) (*model.UpdateResult, error)
func (*DataStoreMongo) UpsertDevicesAttributesWithUpdated ¶
func (db *DataStoreMongo) UpsertDevicesAttributesWithUpdated( ctx context.Context, ids []model.DeviceID, attrs model.DeviceAttributes, scope string, etag string, ) (*model.UpdateResult, error)
func (*DataStoreMongo) UpsertRemoveDeviceAttributes ¶
func (db *DataStoreMongo) UpsertRemoveDeviceAttributes( ctx context.Context, id model.DeviceID, updateAttrs model.DeviceAttributes, removeAttrs model.DeviceAttributes, scope string, etag string, ) (*model.UpdateResult, error)
func (*DataStoreMongo) WithAutomigrate ¶
func (db *DataStoreMongo) WithAutomigrate() store.DataStore
WithAutomigrate enables automatic migration and returns a new datastore based on current one
Click to show internal directories.
Click to hide internal directories.