func (c CreateEdge) Do(d *DGraphAccess) (created bool, fail error) {
	if err := d.CheckState(); err != nil {
		return false, err
	}
	// create subject if new Node
	if c.Subject.GetUID().IsZero() {
		if err := d.Service().CreateNode(c.Subject); err != nil {
			return false, err
		}
	}
	// create object if new Node
	object := c.Object
	if huid, ok := c.Object.(HasUID); ok {
		if huid.GetUID().IsZero() {
			if err := d.Service().CreateNode(huid); err != nil {
				return false, err
			}
		}
		object = huid.GetUID()
	}
	nq := NQuad{
		Subject:   c.Subject.GetUID(),
		Predicate: c.Predicate,
		Object:    object,
		Facets:    c.Facets,
	}
	nQuads := nq.Bytes()
	if d.traceEnabled {
		trace("CreateEdge", "nquad", string(nQuads))
	}
	_, err := d.txn.Mutate(d.ctx, &api.Mutation{SetNquads: nQuads})
	return true, err
}
// Do creates a new Edge (using an NQuad).
// If Subject is a non-created Node than create it first ; abort if error
// If Object is a non-created Node than create it first ; abort if error
// Returns an error if the mutation fails.
// Returns whether the edge was created when the absent check was requested.
// Requires a DGraphAccess with a Write transaction.
Do creates a new Edge (using an NQuad).
If Subject is a non-created Node than create it first ; abort if error
If Object is a non-created Node than create it first ; abort if error
Returns an error if the mutation fails.
Returns whether the edge was created when the absent check was requested.
Requires a DGraphAccess with a Write transaction.
// Do creates a new Edge ( using an NQuad ) . // If Subject is a non - created Node than create it first ; abort if error // If Object is a non - created Node than create it first ; abort if error // Returns an error if the mutation fails . // Returns whether the edge was created when the absent check was requested . // Requires a DGraphAccess with a Write transaction .
func (c CreateEdge) Do(d *DGraphAccess) (created bool, fail error) {
	if err := d.CheckState(); err != nil {
		return false, err
	}
	if c.Subject.GetUID().IsZero() {
		if err := d.Service().CreateNode(c.Subject); err != nil {
			return false, err
		}
	}
	object := c.Object
	if huid, ok := c.Object.(HasUID); ok {
		if huid.GetUID().IsZero() {
			if err := d.Service().CreateNode(huid); err != nil {
				return false, err
			}
		}
		object = huid.GetUID()
	}
	nq := NQuad{
		Subject:   c.Subject.GetUID(),
		Predicate: c.Predicate,
		Object:    object,
		Facets:    c.Facets,
	}
	nQuads := nq.Bytes()
	if d.traceEnabled {
		trace("CreateEdge", "nquad", string(nQuads))
	}
	_, err := d.txn.Mutate(d.ctx, &api.Mutation{SetNquads: nQuads})
	return true, err
}
func ( c CreateEdge ) Do ( d * DGraphAccess ) ( created bool , fail error ) { if err := d . CheckState ( ) ; err != nil { return false , err } if c . Subject . GetUID ( ) . IsZero ( ) { if err := d . Service ( ) . CreateNode ( c . Subject ) ; err != nil { return false , err } } object := c . Object if huid , ok := c . Object . ( HasUID ) ; ok { if huid . GetUID ( ) . IsZero ( ) { if err := d . Service ( ) . CreateNode ( huid ) ; err != nil { return false , err } } object = huid . GetUID ( ) } nq := NQuad { Subject : c . Subject . GetUID ( ) , Predicate : c . Predicate , Object : object , Facets : c . Facets , } nQuads := nq . Bytes ( ) if d . traceEnabled { trace ( " " , " " , string ( nQuads ) ) } _ , err := d . txn . Mutate ( d . ctx , & api . Mutation { SetNquads : nQuads } ) return true , err }
Do creates a new Edge (using an NQuad).
Do creates a new Edge ( using an NQuad ) .
// create subject if new Node // create object if new Node