1
0
mirror of https://github.com/mainflux/mainflux.git synced 2025-04-29 13:49:28 +08:00
Mirko Teodorovic d20dfa84bc NOISSUE - Search by metadata (#849)
* add metadata search

Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>

* add metadata search

Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>

* add metadata search

Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>

* add metadata search

Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>

* add metadata search

Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>

* add metadata search

Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>

* add metadata search

Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>

* add space

Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>

* metadata test case

Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>

* add docs and update swagger

Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>

* add test for metadata

Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>

* add test for metadata

Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>

* remove commented out section

Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>

* small change to test

Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>

* remove debug printf

Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>

* small fix for metadata

Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>

* fix tests

Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>

* and => and/or

Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>

* add line

Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>

* fix mixed func params

Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>

* metadata will be added to channels later

Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>

* fix return type

Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>

* fix typings

Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>

* fix typings

Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>

* add migration

Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>

* remove var

Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>

* respecting the order of migrations

Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>
2019-09-17 15:46:24 +02:00

77 lines
2.3 KiB
Go

//
// Copyright (c) 2019
// Mainflux
//
// SPDX-License-Identifier: Apache-2.0
//
package things
import "context"
// Metadata to be used for mainflux thing for customized
// describing of particular thing
type ThingMetadata map[string]interface{}
// Thing represents a Mainflux thing. Each thing is owned by one user, and
// it is assigned with the unique identifier and (temporary) access key.
type Thing struct {
ID string
Owner string
Name string
Key string
Metadata ThingMetadata
}
// ThingsPage contains page related metadata as well as list of things that
// belong to this page.
type ThingsPage struct {
PageMetadata
Things []Thing
}
// ThingRepository specifies a thing persistence API.
type ThingRepository interface {
// Save persists the thing. Successful operation is indicated by non-nil
// error response.
Save(context.Context, Thing) (string, error)
// Update performs an update to the existing thing. A non-nil error is
// returned to indicate operation failure.
Update(context.Context, Thing) error
// UpdateKey updates key value of the existing thing. A non-nil error is
// returned to indicate operation failure.
UpdateKey(context.Context, string, string, string) error
// RetrieveByID retrieves the thing having the provided identifier, that is owned
// by the specified user.
RetrieveByID(context.Context, string, string) (Thing, error)
// RetrieveByKey returns thing ID for given thing key.
RetrieveByKey(context.Context, string) (string, error)
// RetrieveAll retrieves the subset of things owned by the specified user.
RetrieveAll(context.Context, string, uint64, uint64, string, ThingMetadata) (ThingsPage, error)
// RetrieveByChannel retrieves the subset of things owned by the specified
// user and connected to specified channel.
RetrieveByChannel(context.Context, string, string, uint64, uint64) (ThingsPage, error)
// Remove removes the thing having the provided identifier, that is owned
// by the specified user.
Remove(context.Context, string, string) error
}
// ThingCache contains thing caching interface.
type ThingCache interface {
// Save stores pair thing key, thing id.
Save(context.Context, string, string) error
// ID returns thing ID for given key.
ID(context.Context, string) (string, error)
// Removes thing from cache.
Remove(context.Context, string) error
}