db

package
v0.0.0-...-4de6f6b Latest Latest
Warning

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

Go to latest
Published: Jun 6, 2020 License: Apache-2.0 Imports: 15 Imported by: 3

Documentation

Index

Constants

View Source
const CacheKey = "dbSchema"

CacheKey - Define key name for LruCache

Variables

View Source
var InitLruCacheDBSchema bool

InitLruCacheDBSchema - a flag to indicate if LruCache has initial DBSchema when server starts

View Source
var LruCache *lru.Cache

LruCache - Define type LRU Cache

Functions

This section is empty.

Types

type Action

type Action int

Action as oper

type DGClient

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

DGClient will run query or command on dgraph

func NewDGClient

func NewDGClient(dgraphHost string) *DGClient

NewDGClient create client instance TODO: consider to return single client stub without close connection

func (DGClient) Close

func (s DGClient) Close() error

Close - destroy connection

func (DGClient) CreateEntity

func (s DGClient) CreateEntity(meta string, data map[string]interface{}) (string, error)

CreateEntity - create entity

func (DGClient) CreateOrDeleteEdge

func (s DGClient) CreateOrDeleteEdge(fromType string, fromUID string, toType string, toUID string, rel string, op Action) error

CreateOrDeleteEdge - create or remove edge

func (DGClient) CreateSchema

func (s DGClient) CreateSchema(sm Schema) error

CreateSchema - create index

func (DGClient) DeleteEntity

func (s DGClient) DeleteEntity(uuid string) error

DeleteEntity - delete entity by uuid

func (DGClient) DropSchema

func (s DGClient) DropSchema(name string) error

DropSchema remove db schema by name

func (DGClient) ExecuteDgraphQuery

func (s DGClient) ExecuteDgraphQuery(query string) (map[string]interface{}, error)

ExecuteDgraphQuery - Takes a dgraph query as a string and executes on a dgraph instance

func (DGClient) GetAllByClusterAndType

func (s DGClient) GetAllByClusterAndType(meta string, cluster string) (map[string]interface{}, error)

GetAllByClusterAndType - query to get result by filter edge

func (DGClient) GetCacheContainsDBSchema

func (s DGClient) GetCacheContainsDBSchema() (*lru.Cache, error)

GetCacheContainsDBSchema - Get cache which contains db schema

func (DGClient) GetEntity

func (s DGClient) GetEntity(uuid string) (map[string]interface{}, error)

GetEntity - get entity by uid

func (DGClient) GetQueryResult

func (s DGClient) GetQueryResult(query string) (map[string]interface{}, error)

GetQueryResult - get Query Results

func (DGClient) GetSchemaFromCache

func (s DGClient) GetSchemaFromCache(cache *lru.Cache) ([]*api.SchemaNode, error)

GetSchemaFromCache - Get db schema from cache

func (DGClient) GetSchemaFromDB

func (s DGClient) GetSchemaFromDB() ([]*api.SchemaNode, error)

GetSchemaFromDB - get all predicates

func (DGClient) RemoveDBSchemaFromCache

func (s DGClient) RemoveDBSchemaFromCache(cache *lru.Cache)

RemoveDBSchemaFromCache - remove DBSchema key from the Cache

func (DGClient) UpdateEntity

func (s DGClient) UpdateEntity(uuid string, data map[string]interface{}, option ...util.OptionContext) error

UpdateEntity - update entity

type IDGClient

type IDGClient interface {
	GetCacheContainsDBSchema() (*lru.Cache, error)
	GetSchemaFromCache(cache *lru.Cache) ([]*api.SchemaNode, error)
	RemoveDBSchemaFromCache(cache *lru.Cache)
	GetSchemaFromDB() ([]*api.SchemaNode, error)
	CreateSchema(sm Schema) error
	DropSchema(name string) error
	GetEntity(uuid string) (map[string]interface{}, error)
	GetAllByClusterAndType(meta string, cluster string) (map[string]interface{}, error)
	DeleteEntity(uuid string) error
	CreateEntity(meta string, data map[string]interface{}) (string, error)
	CreateOrDeleteEdge(fromType string, fromUID string, toType string, toUID string, rel string, op Action) error
	UpdateEntity(uuid string, data map[string]interface{}, option ...util.OptionContext) error
	GetQueryResult(query string) (map[string]interface{}, error)
	Close() error
	ExecuteDgraphQuery(query string) (map[string]interface{}, error)
}

IDGClient ... define interface to DGClient

type Schema

type Schema struct {
	Predicate string   `json:"predicate"`
	Type      string   `json:"type"`
	List      bool     `json:"list,omitempty"`
	Index     bool     `json:"index,omitempty"`
	Upsert    bool     `json:"upsert,omitempty"`
	Count     bool     `json:"count,omitempty"`
	Reverse   bool     `json:"reverse,omitempty"`
	Tokenizer []string `json:"tokenizer,omitempty"`
}

Schema dgraph database schema

Jump to

Keyboard shortcuts

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