Documentation
¶
Index ¶
- Variables
- func GetTransaction(hostName string) (*dgo.Txn, error)
- func InitInstances(configs []Host) error
- func NewClient(h Host) (*dgo.Dgraph, error)
- type DGraphDAO
- func (dg *DGraphDAO) CreateSchema(ctx context.Context, schema string) error
- func (dg *DGraphDAO) DeleteData(ctx context.Context, data []byte) error
- func (dg *DGraphDAO) DeleteDataTXN(ctx context.Context, txn *dgo.Txn, data []byte) error
- func (dg *DGraphDAO) DeleteEdge(ctx context.Context, uid string, predicates ...string) error
- func (dg *DGraphDAO) DeleteEdgeTXN(ctx context.Context, txn *dgo.Txn, uid string, predicates ...string) error
- func (dg *DGraphDAO) DropAttr(ctx context.Context, attr string) error
- func (dg *DGraphDAO) DropData(ctx context.Context) error
- func (dg *DGraphDAO) DropSchema(ctx context.Context) error
- func (dg *DGraphDAO) GetData(ctx context.Context, query string, vars map[string]string) ([]byte, error)
- func (dg *DGraphDAO) SetData(ctx context.Context, data []byte) error
- func (dg *DGraphDAO) SetDataTXN(ctx context.Context, txn *dgo.Txn, data []byte) error
- type Host
- type Instance
Constants ¶
This section is empty.
Variables ¶
var ( ErrNotConfigured = errors.New("graph db instances not configured. InitInstances() must be called to configure.") ErrInstanceNotFound = errors.New("graph db instance not found") )
Functions ¶
func GetTransaction ¶
GetTransaction returns a new transaction for provided host.
If hostname is empty, transaction from default host will be returned.
Otherwise ErrInstanceNotFound error will be returned.
func InitInstances ¶
Types ¶
type DGraphDAO ¶
type DGraphDAO struct { HostName string // contains filtered or unexported fields }
func GetDAO ¶
GetDAO returns a dao instance to access and manipulate graph data and schema.
If hostname is empty, default host will be used.
Otherwise ErrInstanceNotFound error will be returned.
func (*DGraphDAO) CreateSchema ¶
CreateSchema sets the provided schema for the nodes data.
func (*DGraphDAO) DeleteData ¶
DeleteData deletes the node or provided node attribute.
func (*DGraphDAO) DeleteDataTXN ¶
DeleteData deletes the node or provided node attribute.
The transacction must be committed or discarded.
func (*DGraphDAO) DeleteEdge ¶
DeleteEdge deletes the edges for the mentioned node. predicate is the name of relationship between the node.
Ex. Persion1 `follows` Person2.
func (*DGraphDAO) DeleteEdgeTXN ¶
func (dg *DGraphDAO) DeleteEdgeTXN(ctx context.Context, txn *dgo.Txn, uid string, predicates ...string) error
DeleteEdgeTXN deletes the edges for the mentioned node. predicate is the name of relationship between the node.
Ex. Persion1 `follows` Person2.
func (*DGraphDAO) DropAttr ¶
DropAttr deletes a specific attribute completely from data and the schema.
func (*DGraphDAO) DropSchema ¶
DropSchema deletes the current schema along with the data.
func (*DGraphDAO) GetData ¶
func (dg *DGraphDAO) GetData(ctx context.Context, query string, vars map[string]string) ([]byte, error)
GetData returns the nodes matching to the provided query.
query variables can be provided in `vars` param. Safe to provide `nil` if no variables required.
The result is against the provided key in the query.
type Instance ¶
type Instance struct {
// contains filtered or unexported fields
}
func GetInstance ¶
GetInstance returns a preconfigured dgraph instance from cache. If not present, returns an error.
func NewInstance ¶
NewInstance creates n new v2 instance of dgraph client. This instance can be saved in cache with host name as identifier for further operations.