Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Option ¶
type Option struct {
Targets []string `json:"targets"`
Credential credential `json:"credential"`
}
type Proxy ¶
type Proxy interface {
// Alter can be used to set schema.
// For example:
// op := &api.Operation{
// Schema: `name: string @index(exact) .`,
// RunInBackground: true
// }
Alter(ctx context.Context, op *api.Operation) error
// Transaction should be called normally to run a Mutation or Upsert(Query + Mutation).
// For example:
// (Mutation)
// type Person struct {
// Name string `json:"name,omitempty"`
// }
// p := Persion{Name: "xxx"}
// b, err := json.Marshal(p)
// mu := &api.Mutation{
// SetJson: b,
// }
// req := &api.Request{CommitNow: true, Mutations: []*api.Mutation{mu}}
// rsp, err := Transaction(ctx, req)
// (Query + Mutation) WITHOUT conditions
// q := `query {user as var(func: eq(email, "wrong_email@example.com"))}`
// mu := &api.Mutation{SetNquads: []byte(`uid(user) <email> "correct_email@example.com" .`)}
// req := &api.Request{Query: q, Mutations: []*api.Mutation{mu}, CommitNow: true}
// rsp, err := Transaction(ctx, req)
// (Query + Mutation) WITH conditions
// q := `query {user as var(func: eq(email, "wrong_email@example.com"))}`
// mu := &api.Mutation{
// Cond: `@if(eq(len(user), 1))`,
// SetNquads: []byte(`uid(user) <email> "correct_email@example.com" .`),
// }
// req := &api.Request{Query: q, Mutations: []*api.Mutation{mu}, CommitNow: true}
// rsp, err := Transaction(ctx, req)
Transaction(ctx context.Context, req *api.Request) ([]byte, error)
// Query can be used in two ways, including general query and query with variables.
// It is useful to increase read speed.
// the param of `vars` can be nil if you do not want to pass variables to the Query statements.
Query(ctx context.Context, q string, vars map[string]string) ([]byte, error)
}
Proxy represents a collection of methods to operate dGraph
Click to show internal directories.
Click to hide internal directories.