dgraph

package
v0.0.40 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 7, 2022 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New() *dGraph

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

func Client

func Client() Proxy

Client returns the handler to operate mysql if success

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL