Documentation
¶
Overview ¶
Package xdgraph provides a simple helper for manipulating Dgraph gRPC responses.
Index ¶
- type Property
- func (p Property) IsNil() bool
- func (p Property) String() string
- func (p Property) ToBool() bool
- func (p Property) ToBytes() []byte
- func (p Property) ToDateTime() time.Time
- func (p Property) ToFloat() float64
- func (p Property) ToGeo() geom.T
- func (p Property) ToInt() int64
- func (p Property) ToPassword() string
- func (p Property) ToString() string
- func (p Property) ToUid() uint64
- type Response
- func (r Response) Attribute(name string) Response
- func (r Response) Each(fn func(Response))
- func (r Response) First() Response
- func (r Response) IsNil() bool
- func (r Response) Json() string
- func (r Response) Properties(name string) []Property
- func (r Response) Property(name string) Property
- func (r Response) String() string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Property ¶
type Property struct {
// contains filtered or unexported fields
}
Property is a struct that carries the current graph.Value.
func (Property) ToDateTime ¶
ToDateTime returns the property as a time.Time
func (Property) ToPassword ¶
ToPassword returns the property as a string
type Response ¶
type Response struct {
// contains filtered or unexported fields
}
Response is a struct that carries the current graph.Node.
func ReadResponse ¶
ReadResponse is the entry point of this package It takes in parameter the response from a gRPC call:
resp, _ := c.Run(...) xd := xdgraph.ReadResponse(resp) [...]
func (Response) Attribute ¶
Attribute moves to the given attribute name. It must be a children of the current attribute. This can be asserted using the IsNil() function.
func (Response) Each ¶
Each will run the provided function for each elements contained in the response. Example:
xd.First().Attribute("follows").Each(func(r xdgraph.Response) {
fmt.Println(r.Property("name").ToString())
})
func (Response) First ¶
First can be used to access the first attribute without explicitely giving its name.
func (Response) Properties ¶
Properties returns a slice of properties by name.