// Save creates the Grant in the database.
Save creates the Grant in the database.
// Save creates the Grant in the database .
func (gc *GrantCreate) Save(ctx context.Context) (*Grant, error) {
	var (
		err  error
		node *Grant
	)
	gc.defaults()
	if len(gc.hooks) == 0 {
		if err = gc.check(); err != nil {
			return nil, err
		}
		node, err = gc.sqlSave(ctx)
	} else {
		var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
			mutation, ok := m.(*GrantMutation)
			if !ok {
				return nil, fmt.Errorf("unexpected mutation type %T", m)
			}
			if err = gc.check(); err != nil {
				return nil, err
			}
			gc.mutation = mutation
			node, err = gc.sqlSave(ctx)
			mutation.done = true
			return node, err
		})
		for i := len(gc.hooks) - 1; i >= 0; i-- {
			mut = gc.hooks[i](mut)
		}
		if _, err := mut.Mutate(ctx, gc.mutation); err != nil {
			return nil, err
		}
	}
	return node, err
}
func ( gc * GrantCreate ) Save ( ctx context . Context ) ( * Grant , error ) { var ( err error node * Grant ) gc . defaults ( ) if len ( gc . hooks ) == 0 { if err = gc . check ( ) ; err != nil { return nil , err } node , err = gc . sqlSave ( ctx ) } else { var mut Mutator = MutateFunc ( func ( ctx context . Context , m Mutation ) ( Value , error ) { mutation , ok := m . ( * GrantMutation ) if ! ok { return nil , fmt . Errorf ( " " , m ) } if err = gc . check ( ) ; err != nil { return nil , err } gc . mutation = mutation node , err = gc . sqlSave ( ctx ) mutation . done = true return node , err } ) for i := len ( gc . hooks ) - 1 ; i >= 0 ; i -- { mut = gc . hooks [ i ] ( mut ) } if _ , err := mut . Mutate ( ctx , gc . mutation ) ; err != nil { return nil , err } } return node , err }
Save creates the Grant in the database.
Save creates the Grant in the database .