Documentation ¶
Overview ¶
Package ndgo <read iNDiGO> provides dgo abstractions and helpers - github.com/ppp225/ndgo
Index ¶
- func Debug()
- type DeleteJSON
- type DeleteRDF
- type Query
- func (Query) DeleteEdge(from, predicate, to string) DeleteRDF
- func (Query) DeleteNode(uid string) DeleteRDF
- func (Query) DeletePred(uid, predicate string) DeleteRDF
- func (Query) GetPredExpandType(blockID, fx, pred, val, funcParams, directives, dgPreds, dgTypes string) QueryDQL
- func (Query) GetUIDExpandType(blockID, fx, uid, funcParams, directives, dgPreds, dgTypes string) QueryDQL
- func (Query) SetEdge(from, predicate, to string) SetRDF
- func (Query) SetPred(uid, predicate, value string) SetRDF
- type QueryDQL
- type SetJSON
- type SetRDF
- type Txn
- func (v *Txn) Commit() (err error)
- func (v *Txn) Deleteb(json, rdf []byte) (resp *api.Response, err error)
- func (v *Txn) Deletei(jsonMutations ...interface{}) (resp *api.Response, err error)
- func (v *Txn) Deletenq(rdf string) (resp *api.Response, err error)
- func (v *Txn) Discard()
- func (v *Txn) Do(req *api.Request) (resp *api.Response, err error)
- func (v *Txn) DoSetb(query, cond string, json, rdf []byte) (resp *api.Response, err error)
- func (v *Txn) DoSeti(query string, jsonMutations ...interface{}) (resp *api.Response, err error)
- func (v *Txn) DoSetnq(query, nquads string) (resp *api.Response, err error)
- func (v *Txn) GetDatabaseTime() float64
- func (v *Txn) GetNetworkTime() float64
- func (v *Txn) Mutate(mu *api.Mutation) (resp *api.Response, err error)
- func (v *Txn) Query(q string) (resp *api.Response, err error)
- func (v *Txn) QueryWithVars(q string, vars map[string]string) (resp *api.Response, err error)
- func (v *Txn) Setb(json, rdf []byte) (resp *api.Response, err error)
- func (v *Txn) Seti(jsonMutations ...interface{}) (resp *api.Response, err error)
- func (v *Txn) Setnq(rdf string) (resp *api.Response, err error)
- type Unsafe
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type DeleteJSON ¶
type DeleteJSON string
DeleteJSON represents a dgraph delete mutation string with some methods defined
func (DeleteJSON) Join ¶
func (v DeleteJSON) Join(json DeleteJSON) DeleteJSON
Join allows to join multiple json Query of same type
type DeleteRDF ¶
type DeleteRDF string
DeleteRDF represents a dgraph delete rdf mutation string with some methods defined
type Query ¶
type Query struct{}
Query groups. Usage: ndgo.Query{}... It's recommended to create your own helpers, than to use the build in ones.
func (Query) DeleteEdge ¶
DeleteEdge Usage: _, err = ndgo.Query{}.DeleteEdge(parentUID, "edgeName", childUID).Run(txn)
func (Query) DeleteNode ¶
DeleteNode Usage: _, err = ndgo.Query{}.DeleteNode(UID).Run(txn)
func (Query) DeletePred ¶
DeletePred Usage: ndgo.Query{}.DeletePred(from, predicate)
func (Query) GetPredExpandType ¶
func (Query) GetPredExpandType(blockID, fx, pred, val, funcParams, directives, dgPreds, dgTypes string) QueryDQL
GetPredExpandType constructs a complete query. It's for convenience, so formatting can be done only once. Also one liner! Usage: resp, err := ndgo.Query{}.GetPredExpandType("q", "eq", predicate, value, ",first:1", "", "uid dgraph.type", dgTypes).Run(txn)
func (Query) GetUIDExpandType ¶
func (Query) GetUIDExpandType(blockID, fx, uid, funcParams, directives, dgPreds, dgTypes string) QueryDQL
GetUIDExpandType constructs a complete query. It's for convenience, so formatting can be done only once. Also one liner! Usage: resp, err := ndgo.Query{}.GetUIDExpandType("q", "uid", uid, "", "", "", "_all_").Run(txn)
type QueryDQL ¶
type QueryDQL string
QueryDQL represents a dgraph query string with some methods defined
type SetJSON ¶
type SetJSON string
SetJSON represents a dgraph set mutation string with some methods defined
type SetRDF ¶
type SetRDF string
SetRDF represents a dgraph set rdf mutation string with some methods defined
type Txn ¶
type Txn struct {
// contains filtered or unexported fields
}
Txn is a dgo.Txn wrapper with additional diagnostic data Helps with Queries, by providing abstractions for dgraph Query and Mutation
func NewTxnWithoutContext ¶
func NewTxnWithoutContext(txn *dgo.Txn) *Txn
NewTxnWithoutContext creates new Txn (without ctx)
func (*Txn) Deletei ¶
Deletei is equivalent to Deleteb, but it marshalls structs into one slice of mutations
func (*Txn) Discard ¶
func (v *Txn) Discard()
Discard cleans up dgo.Txn resources. Always defer this on creation.
func (*Txn) Do ¶
Do executes a query followed by one or more mutations. Possible to run query without mutations, or vice versa
func (*Txn) GetDatabaseTime ¶
GetDatabaseTime gets time txn spend in db
func (*Txn) GetNetworkTime ¶
GetNetworkTime gets total time until response
func (*Txn) QueryWithVars ¶
QueryWithVars performs dgraph query with vars
type Unsafe ¶
type Unsafe struct{}
Unsafe collects helpers, which require knowledge of how they work to operate correctly
func (Unsafe) FlattenRespToArray ¶
FlattenRespToArray flattens resp.GetJson() to only contain array without query block. i.e. transforms `{"q":[...]}` to `[...]`. QueryBlockID must be single letter. One QueryBlock supported, otherwise will return gibberish and unmarshal will error.
func (Unsafe) FlattenRespToObject ¶
FlattenRespToObject flattens resp.GetJson() to only contain a single object, without array or query block. i.e. transforms `{"q":[{...}]}` to `{...}`. QueryBlockID must be single letter. One QueryBlock supported. Response array should only have 0 or 1 object, otherwise will return gibberish and unmarshal will error.