Documentation ¶
Overview ¶
Package graph is a protobuf-based library that can be used to safely generate arbitrary Neo4j graph queries. Its subpackage, graphpb, has five main types
ReadQuery MergeQuery CreateQuery DeleteQuery RemoveQuery
as well as a wrapper type—Query—that contains one of the above five types.
The goal of package graph is to provide a way to write structured Cypher queries in a safe, easy manner. The structured nature of the five main query types allows the backend server to, for example, reject writes when only reads are allowed or modify the request after it's received. Package graph can also be the base of an ORM.
graph provides some convenience features such as a default LIMIT, type-checked functions, checking for balanced parenthases in mathematical equations, and detection of unused parameters.
Index ¶
- Constants
- func QuoteIdent(s string) string
- type Generator
- func (g *Generator) Create(c *gpb.CreateQuery) (string, map[string]interface{}, error)
- func (g *Generator) Cypher(obj interface{}) (string, map[string]interface{}, error)
- func (g *Generator) Delete(d *gpb.DeleteQuery) (string, map[string]interface{}, error)
- func (g *Generator) Merge(m *gpb.MergeQuery) (string, map[string]interface{}, error)
- func (g *Generator) Read(r *gpb.ReadQuery) (string, map[string]interface{}, error)
- func (g *Generator) Remove(d *gpb.RemoveQuery) (string, map[string]interface{}, error)
- type Option
- type Writer
Constants ¶
const DefaultMaxLimit = 100
DefaultMaxLimit is the default maximum LIMIT if, upon creation of a Generator, its limit is <= 0.
Variables ¶
This section is empty.
Functions ¶
func QuoteIdent ¶
QuoteIdent quotes a Neo4j identifier in backticks, escaping all backticks.
Types ¶
type Generator ¶
type Generator struct {
// contains filtered or unexported fields
}
Generator generates Cypher and corresponding parameters from a protocol buffer object. It may be reused, but not concurrently.
func NewGenerator ¶
NewGenerator creates a Generator from the provided options.
func (*Generator) Create ¶
Create converts a CreateQuery object to its resulting Cypher query format and returns the query along with any arguments and an error, if any.
func (*Generator) Cypher ¶
Cypher converts a queryQuery object to its resulting Cypher query format and returns the query along with any arguments and an error, if any.
func (*Generator) Delete ¶
Delete converts a DeleteQuery object to its resulting Cypher query format and returns the query along with any arguments and an error, if any.
func (*Generator) Merge ¶
Merge converts a MergeQuery object to its resulting Cypher query format and returns the query along with any arguments and an error, if any.
type Option ¶
type Option func(*Generator)
Option is a configuration option for a Generator.
func WithMaxLimit ¶
WithMaxLimit sets the largest LIMIT value the Generator will allow.