Documentation ¶
Index ¶
- Constants
- type DirFileStore
- func (store *DirFileStore) AutoSaveLoop()
- func (store *DirFileStore) Close()
- func (store *DirFileStore) Get(thingID string) (interface{}, error)
- func (store *DirFileStore) List(offset int, limit int, aclFilter func(thingID string) bool) []interface{}
- func (store *DirFileStore) Open() error
- func (store *DirFileStore) Patch(id string, src map[string]interface{}) error
- func (store *DirFileStore) Query(jsonPath string, offset int, limit int, aclFilter func(thingID string) bool) ([]interface{}, error)
- func (store *DirFileStore) Remove(id string)
- func (store *DirFileStore) Replace(id string, document map[string]interface{}) error
Constants ¶
const DefaultListLimit = 100
Max nr of items to return in list
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DirFileStore ¶
type DirFileStore struct {
// contains filtered or unexported fields
}
DirFileStore is a crude little file based Directory store Intended as a testing MVP for the directory service Implements the IDirStore interface
func NewDirFileStore ¶
func NewDirFileStore(jsonFilePath string) *DirFileStore
Create a new directory file store instance
filePath path to JSON store file
func (*DirFileStore) AutoSaveLoop ¶
func (store *DirFileStore) AutoSaveLoop()
AutoSaveLoop periodically saves changes to the directory
func (*DirFileStore) Get ¶
func (store *DirFileStore) Get(thingID string) (interface{}, error)
Get a document by its ID
id of the thing to look up
Returns an error if it doesn't exist
func (*DirFileStore) List ¶
func (store *DirFileStore) List(offset int, limit int, aclFilter func(thingID string) bool) []interface{}
Return a list of documents
offset is the offset in the document list that is sorted by document ID limit is the maximum nr of documents to return or 0 for the default aclFilter filters the things by ID. Use nil to ignore.
This returns an empty list if offset is equal or larger than the available nr of documents
func (*DirFileStore) Open ¶
func (store *DirFileStore) Open() error
Open the store Returns error if it can't be opened or already open
func (*DirFileStore) Patch ¶
func (store *DirFileStore) Patch(id string, src map[string]interface{}) error
Patch a document Returns an error if it doesn't exist
func (*DirFileStore) Query ¶
func (store *DirFileStore) Query(jsonPath string, offset int, limit int, aclFilter func(thingID string) bool) ([]interface{}, error)
Query for documents using JSONPATH Eg `$[? @.properties.deviceType=="sensor"]`
jsonPath contains the query offset contains the offset in the list of results, sorted by ID limit contains the maximum or of responses, 0 for the default 100
func (*DirFileStore) Remove ¶
func (store *DirFileStore) Remove(id string)
Remove a document from the store Also succeeds if the document doesn't exist