func (r *Repo) SaveBundle(ctx context.Context, bundle *fb.Bundle) error {
	if _, err := r.CurrentUser(); err != nil {
		return err
	}
	if bundle == nil {
		return errors.New("nil bundle")
	}
	if err := bundle.Validate(); err != nil {
		return errors.Wrap(err, "invalid bundle")
	}
	udb, err := r.userDB(ctx)
	if err != nil {
		return errors.Wrap(err, "userDB")
	}
	bdb, err := r.bundleDB(ctx, bundle)
	if err != nil {
		return errors.Wrap(err, "bundleDB")
	}
	if err := saveDoc(ctx, bdb, bundle); err != nil {
		return errors.Wrap(err, "bundle db write")
	}
	bundle.Rev = ""
	if err := saveDoc(ctx, udb, bundle); err != nil {
		return errors.Wrap(err, "user db write")
	}
	return nil
}
// SaveBundle saves the bundle.
SaveBundle saves the bundle.
// SaveBundle saves the bundle .
func (r *Repo) SaveBundle(ctx context.Context, bundle *fb.Bundle) error {
	if _, err := r.CurrentUser(); err != nil {
		return err
	}
	if bundle == nil {
		return errors.New("nil bundle")
	}
	if err := bundle.Validate(); err != nil {
		return errors.Wrap(err, "invalid bundle")
	}
	udb, err := r.userDB(ctx)
	if err != nil {
		return errors.Wrap(err, "userDB")
	}
	bdb, err := r.bundleDB(ctx, bundle)
	if err != nil {
		return errors.Wrap(err, "bundleDB")
	}
	if err := saveDoc(ctx, bdb, bundle); err != nil {
		return errors.Wrap(err, "bundle db write")
	}
	bundle.Rev = ""
	if err := saveDoc(ctx, udb, bundle); err != nil {
		return errors.Wrap(err, "user db write")
	}
	return nil
}
func ( r * Repo ) SaveBundle ( ctx context . Context , bundle * fb . Bundle ) error { if _ , err := r . CurrentUser ( ) ; err != nil { return err } if bundle == nil { return errors . New ( " " ) } if err := bundle . Validate ( ) ; err != nil { return errors . Wrap ( err , " " ) } udb , err := r . userDB ( ctx ) if err != nil { return errors . Wrap ( err , " " ) } bdb , err := r . bundleDB ( ctx , bundle ) if err != nil { return errors . Wrap ( err , " " ) } if err := saveDoc ( ctx , bdb , bundle ) ; err != nil { return errors . Wrap ( err , " " ) } bundle . Rev = " " if err := saveDoc ( ctx , udb , bundle ) ; err != nil { return errors . Wrap ( err , " " ) } return nil }
SaveBundle saves the bundle.
SaveBundle saves the bundle .