{"modulePath":"github.com/facebook/ent","version":"v0.5.4","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package sqlgraph\n\nPackage sqlgraph provides graph abstraction capabilities on top of sql-based databases for ent codegen.\n\n## Constants\n\n```go\nconst FuncSelector entql.Func = \"func_selector\"\n```\nFuncSelector represents a selector function to be used as an entql foreign-function.\n\n## Functions\n\n```go\nfunc BatchCreate(ctx context.Context, drv dialect.Driver, spec *BatchCreateSpec) error\n```\nBatchCreate applies the BatchCreateSpec on the graph.\n\n```go\nfunc CountNodes(ctx context.Context, drv dialect.Driver, spec *QuerySpec) (int, error)\n```\nCountNodes counts the nodes in the given graph query.\n\n```go\nfunc CreateNode(ctx context.Context, drv dialect.Driver, spec *CreateSpec) error\n```\nCreateNode applies the CreateSpec on the graph.\n\n```go\nfunc DeleteNodes(ctx context.Context, drv dialect.Driver, spec *DeleteSpec) (int, error)\n```\nDeleteNodes applies the DeleteSpec on the graph.\n\n```go\nfunc HasNeighbors(q *sql.Selector, s *Step)\n```\nHasNeighbors applies on the given Selector a neighbors check.\n\n```go\nfunc HasNeighborsWith(q *sql.Selector, s *Step, pred func(*sql.Selector))\n```\nHasNeighborsWith applies on the given Selector a neighbors check. The given predicate applies its filtering on the selector.\n\n```go\nfunc Neighbors(dialect string, s *Step) (q *sql.Selector)\n```\nNeighbors returns a Selector for evaluating the path-step and getting the neighbors of one vertex.\n\n```go\nfunc QueryEdges(ctx context.Context, drv dialect.Driver, spec *EdgeQuerySpec) error\n```\nQueryEdges queries the edges in the graph and scans the result with the given dest function.\n\n```go\nfunc QueryNodes(ctx context.Context, drv dialect.Driver, spec *QuerySpec) error\n```\nQueryNodes queries the nodes in the graph query and scans them to the given values.\n\n```go\nfunc SetNeighbors(dialect string, s *Step) (q *sql.Selector)\n```\nSetNeighbors returns a Selector for evaluating the path-step and getting the neighbors of set of vertices.\n\n```go\nfunc UpdateNode(ctx context.Context, drv dialect.Driver, spec *UpdateSpec) error\n```\nUpdateNode applies the UpdateSpec on one node in the graph.\n\n```go\nfunc UpdateNodes(ctx context.Context, drv dialect.Driver, spec *UpdateSpec) (int, error)\n```\nUpdateNodes applies the UpdateSpec on a set of nodes in the graph.\n\n```go\nfunc WrapFunc(s func(*sql.Selector)) *entql.CallExpr\n```\nWrapFunc wraps a selector-func with an entql call expression.\n\n## Types\n\n```go\ntype BatchCreateSpec struct {\n\tNodes []*CreateSpec\n}\n```\nBatchCreateSpec holds the information for creating multiple nodes in the graph.\n\n```go\ntype ConstraintError struct {\n\t// contains filtered or unexported fields\n}\n```\nA ConstraintError represents an error from mutation that violates a specific constraint.\n\n```go\nfunc (e ConstraintError) Error() string\n```\n\n```go\ntype CreateSpec struct {\n\tTable  string\n\tID     *FieldSpec\n\tFields []*FieldSpec\n\tEdges  []*EdgeSpec\n}\n```\nCreateSpec holds the information for creating a node in the graph.\n\n```go\ntype DeleteSpec struct {\n\tNode      *NodeSpec\n\tPredicate func(*sql.Selector)\n}\n```\nDeleteSpec holds the information for delete one or more nodes in the graph.\n\n```go\ntype EdgeMut struct {\n\tAdd   []*EdgeSpec\n\tClear []*EdgeSpec\n}\n```\nEdgeMut defines edge mutations.\n\n```go\ntype EdgeQuerySpec struct {\n\tEdge       *EdgeSpec\n\tPredicate  func(*sql.Selector)\n\tScanValues func() [2]interface{}\n\tAssign     func(out, in interface{}) error\n}\n```\nEdgeQuerySpec holds the information for querying edges in the graph.\n\n```go\ntype EdgeSpec struct {\n\tRel     Rel\n\tInverse bool\n\tTable   string\n\tColumns []string\n\tBidi    bool        // bidirectional edge.\n\tTarget  *EdgeTarget // target nodes.\n}\n```\nEdgeSpec holds the information for updating a field column in the database.\n\n```go\ntype EdgeSpecs []*EdgeSpec\n```\nEdgeSpecs used for perform common operations on list of edges.\n\n```go\nfunc (es EdgeSpecs) FilterRel(r Rel) EdgeSpecs\n```\nFilterRel returns edges for the given relation type.\n\n```go\nfunc (es EdgeSpecs) GroupRel() map[Rel][]*EdgeSpec\n```\nGroupRel groups edges by their relation type.\n\n```go\nfunc (es EdgeSpecs) GroupTable() map[string][]*EdgeSpec\n```\nGroupTable groups edges by their table name.\n\n```go\ntype EdgeTarget struct {\n\tNodes  []driver.Value\n\tIDSpec *FieldSpec\n}\n```\nEdgeTarget holds the information for the target nodes of an edge.\n\n```go\ntype FieldMut struct {\n\tSet   []*FieldSpec // field = ?\n\tAdd   []*FieldSpec // field = field + ?\n\tClear []*FieldSpec // field = NULL\n}\n```\nFieldMut defines field mutations.\n\n```go\ntype FieldSpec struct {\n\tColumn string\n\tType   field.Type\n\tValue  driver.Value // value to be stored.\n}\n```\nFieldSpec holds the information for updating a field column in the database.\n\n```go\ntype Node struct {\n\tNodeSpec\n\n\t// Type holds the node type (schema name).\n\tType string\n\n\t// Fields maps from field names to their spec.\n\tFields map[string]*FieldSpec\n\n\t// Edges maps from edge names to their spec.\n\tEdges map[string]struct {\n\t\tTo   *Node\n\t\tSpec *EdgeSpec\n\t}\n}\n```\nA Node in the graph holds the SQL information for an ent/schema.\n\n```go\ntype NodeSpec struct {\n\tTable   string\n\tColumns []string\n\tID      *FieldSpec\n}\n```\nNodeSpec defines the information for querying and decoding nodes in the graph.\n\n```go\ntype NotFoundError struct {\n\t// contains filtered or unexported fields\n}\n```\nNotFoundError returns when trying to update an entity and it was not found in the database.\n\n```go\nfunc (e *NotFoundError) Error() string\n```\n\n```go\ntype QuerySpec struct {\n\tNode *NodeSpec     // Nodes info.\n\tFrom *sql.Selector // Optional query source (from path).\n\n\tLimit     int\n\tOffset    int\n\tUnique    bool\n\tOrder     func(*sql.Selector)\n\tPredicate func(*sql.Selector)\n\n\tScanValues func(columns []string) ([]interface{}, error)\n\tAssign     func(columns []string, values []interface{}) error\n}\n```\nQuerySpec holds the information for querying nodes in the graph.\n\n```go\ntype Rel int\n```\nRel is a relation type of an edge.\n\n```go\nconst (\n\tO2O Rel // One to one / has one.\n\tO2M     // One to many / has many.\n\tM2O     // Many to one (inverse perspective for O2M).\n\tM2M     // Many to many.\n)\n```\nRelation types.\n\n```go\nfunc (r Rel) String() (s string)\n```\nString returns the relation name.\n\n```go\ntype Schema struct {\n\tNodes []*Node\n}\n```\nA Schema holds a representation of ent/schema at runtime. Each Node represents a single schema-type and its relations in the graph (storage).\n\nIt is used for translating common graph traversal operations to the underlying SQL storage. For example, an operation like \\`has\\_edge(E)\\`, will be translated to an SQL lookup based on the relation type and the FK configuration.\n\n```go\nfunc (g *Schema) AddE(name string, spec *EdgeSpec, from, to string) error\n```\nAddE adds an edge to the graph. It fails, if one of the node types is missing.\n\n\tg.AddE(\"pets\", spec, \"user\", \"pet\")\n\tg.AddE(\"friends\", spec, \"user\", \"user\")\n\n```go\nfunc (g *Schema) EvalP(nodeType string, p entql.P, selector *sql.Selector) error\n```\nEvalP evaluates the entql predicate on the given selector (query builder).\n\n```go\nfunc (g *Schema) MustAddE(name string, spec *EdgeSpec, from, to string)\n```\nMustAddE is like AddE but panics if the edge can be added to the graph.\n\n```go\ntype Step struct {\n\t// From is the source of the step.\n\tFrom struct {\n\t\t// V can be either one vertex or set of vertices.\n\t\t// It can be a pre-processed step (sql.Query) or a simple Go type (integer or string).\n\t\tV interface{}\n\t\t// Table holds the table name of V (from).\n\t\tTable string\n\t\t// Column to join with. Usually the \"id\" column.\n\t\tColumn string\n\t}\n\t// Edge holds the edge information for getting the neighbors.\n\tEdge struct {\n\t\t// Rel of the edge.\n\t\tRel Rel\n\t\t// Table name of where this edge columns reside.\n\t\tTable string\n\t\t// Columns of the edge.\n\t\t// In O2O and M2O, it holds the foreign-key column. Hence, len == 1.\n\t\t// In M2M, it holds the primary-key columns of the join table. Hence, len == 2.\n\t\tColumns []string\n\t\t// Inverse indicates if the edge is an inverse edge.\n\t\tInverse bool\n\t}\n\t// To is the dest of the path (the neighbors).\n\tTo struct {\n\t\t// Table holds the table name of the neighbors (to).\n\t\tTable string\n\t\t// Column to join with. Usually the \"id\" column.\n\t\tColumn string\n\t}\n}\n```\nA Step provides a path-step information to the traversal functions.\n\n```go\nfunc NewStep(opts ...StepOption) *Step\n```\nNewStep gets list of options and returns a configured step.\n\n\tNewStep(\n\t\tFrom(\"table\", \"pk\", V),\n\t\tTo(\"table\", \"pk\"),\n\t\tEdge(\"name\", O2M, \"fk\"),\n\t)\n\n```go\ntype StepOption func(*Step)\n```\nStepOption allows configuring Steps using functional options.\n\n```go\nfunc Edge(rel Rel, inverse bool, table string, columns ...string) StepOption\n```\nEdge sets the edge info for getting the neighbors.\n\n```go\nfunc From(table, column string, v ...interface{}) StepOption\n```\nFrom sets the source of the step.\n\n```go\nfunc To(table, column string) StepOption\n```\nTo sets the destination of the step.\n\n```go\ntype UpdateSpec struct {\n\tNode      *NodeSpec\n\tEdges     EdgeMut\n\tFields    FieldMut\n\tPredicate func(*sql.Selector)\n\n\tScanValues func(columns []string) ([]interface{}, error)\n\tAssign     func(columns []string, values []interface{}) error\n}\n```\nUpdateSpec holds the information for updating one or more nodes in the graph.\n\n","path":"github.com/facebook/ent/dialect/sql/sqlgraph","name":"sqlgraph","synopsis":"Package sqlgraph provides graph abstraction capabilities on top of sql-based databases for ent codegen.","isRedistributable":true}
