dgraph

package
v0.0.0-...-5e70832 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2018 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DebugSchema = true

Functions

func DecodeCursor

func DecodeCursor(after *string) (*string, error)

func DeleteRelationField

func DeleteRelationField(tx *DGraphTxn, ctx context.Context, model interface{}, fieldName string, deleteRelation bool) error

func EncodeCursor

func EncodeCursor(i *string) graphql.ID

func SaveBinder

func SaveBinder(tx *DGraphTxn, ctx context.Context, binder *ModelBinder) (*validate.Errors, error)

func UpdateSchema

func UpdateSchema(tx *DGraphTxn, ctx context.Context, model interface{}, commit bool) error

Types

type BaseAfterDestroy

type BaseAfterDestroy interface {
	AfterDestroy(*DGraphTxn, context.Context) error
}

type BaseAfterSavable

type BaseAfterSavable interface {
	AfterSave(*DGraphTxn, context.Context, string, *ModelBinder) error
}

type BaseAfterSaveableRelation

type BaseAfterSaveableRelation interface {
	AfterSaveRelation(*DGraphTxn, context.Context, *ModelBinder, ...string) error
}

type BaseBeforeDestroy

type BaseBeforeDestroy interface {
	BeforeDestroy(*DGraphTxn, context.Context) error
}

type BaseBinderValidatable

type BaseBinderValidatable interface {
	BinderValidate(*DGraphTxn, context.Context, string, *ModelBinder) (*validate.Errors, error)
}

type BasePreValidatable

type BasePreValidatable interface {
	PreValidate(*DGraphTxn, context.Context, string, *ModelBinder) error
}

type BinderBaseModel

type BinderBaseModel interface {
	BinderInit(*DGraphTxn, context.Context, *ModelBinder) error
}

type DGraphTxn

type DGraphTxn struct {
	Tx     *dgo.Txn
	Client *dgo.Dgraph
}

func NewDGraphTxn

func NewDGraphTxn(connection *grpc.ClientConn) *DGraphTxn

func (*DGraphTxn) Associate

func (d *DGraphTxn) Associate(ctx context.Context, id string, relation string, relatedID string, commit bool) (*api.Assigned, error)

create relation from "id" by relation(name/predicate) to "relatedID"

func (*DGraphTxn) Commit

func (d *DGraphTxn) Commit(ctx context.Context) error

func (*DGraphTxn) DeleteByUID

func (d *DGraphTxn) DeleteByUID(ctx context.Context, uid string, commit bool) (*api.Assigned, error)

Delete an object by id

func (*DGraphTxn) Discard

func (d *DGraphTxn) Discard(ctx context.Context) error

func (*DGraphTxn) Mutate

func (d *DGraphTxn) Mutate(ctx context.Context, mu *api.Mutation) (*api.Assigned, error)

func (*DGraphTxn) MutateDelete

func (d *DGraphTxn) MutateDelete(ctx context.Context, raw string, commit bool) (*api.Assigned, error)
delete {
     <0xf11168064b01135b> <died> "1998" .
  }

func (*DGraphTxn) MutateDeleteField

func (d *DGraphTxn) MutateDeleteField(ctx context.Context, id string, field string, value *api.Value, commit bool) (*api.Assigned, error)

ctx

id object id
predicate
value (nil / api.Value optional) - nil means *
commit bool

func (*DGraphTxn) MutateField

func (d *DGraphTxn) MutateField(ctx context.Context, id string, fieldName string, value interface{}, commit bool) (*api.Assigned, error)

Set value for a predicate by object ID

func (*DGraphTxn) MutateSet

func (d *DGraphTxn) MutateSet(ctx context.Context, sets []*api.NQuad, commit bool) (*api.Assigned, error)

https://docs.dgraph.io/mutations/#triples

func (*DGraphTxn) QueryWithVars

func (d *DGraphTxn) QueryWithVars(ctx context.Context, q string, qVars map[string]string) (*api.Response, error)

func (*DGraphTxn) Save

func (d *DGraphTxn) Save(ctx context.Context, data interface{}, commit bool) (*api.Assigned, error)

func (*DGraphTxn) Schema

func (d *DGraphTxn) Schema(ctx context.Context, schema string) error

func (*DGraphTxn) Transact

func (d *DGraphTxn) Transact(ctx context.Context) error

type SaveCallBack

type SaveCallBack func(*ModelBinder) error

type SaveHelper

type SaveHelper struct {
	// contains filtered or unexported fields
}

func Save

func Save(tx *DGraphTxn, ctx context.Context, dataModel interface{}, values map[string]interface{}, queryFields ...QueryField) *SaveHelper

func SaveIfNotExist

func SaveIfNotExist(tx *DGraphTxn, ctx context.Context, dataModel interface{}, values map[string]interface{},
	where string, whereValues map[string]QVar, queryFields ...QueryField) *SaveHelper

@param tx @param ctx @param modelbinder @param string the where condition @param variables for the where condition @param queryFields - to obtain if exists @return model, created t/f, validation errors, error

func (*SaveHelper) Create

func (s *SaveHelper) Create() (*validate.Errors, error)

func (*SaveHelper) Exec

func (s *SaveHelper) Exec() (bool, *validate.Errors, error)

func (*SaveHelper) On

func (s *SaveHelper) On(event string, callback SaveCallBack) *SaveHelper

Jump to

Keyboard shortcuts

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