func (r *Repo) Sync(ctx context.Context) error {
	u, err := r.CurrentUser()
	if err != nil {
		return err
	}
	udbName := "user-" + u
	rdb := r.remoteDSN(udbName)

	var docsWritten, docsRead int32
	if e := r.doSync(ctx, rdb, udbName, &docsWritten, &docsRead); e != nil {
		return errors.Wrap(e, "sync failed")
	}

	updated, err := r.upgradeSchema(ctx)
	if err != nil {
		return errors.Wrap(err, "schema upgrade failed")
	}
	if updated {
		fmt.Printf("Documents were updated\n")
		if e := r.doSync(ctx, rdb, udbName, &docsWritten, &docsRead); e != nil {
			return errors.Wrap(e, "resync failed")
		}
	}

	log.Debugf("Synced %d docs from server, %d to server\n", docsRead, docsWritten)

	return nil
}
// Sync performs a bi-directional sync.
Sync performs a bi-directional sync.
// Sync performs a bi - directional sync .
func (r *Repo) Sync(ctx context.Context) error {
	u, err := r.CurrentUser()
	if err != nil {
		return err
	}
	udbName := "user-" + u
	rdb := r.remoteDSN(udbName)
	var docsWritten, docsRead int32
	if e := r.doSync(ctx, rdb, udbName, &docsWritten, &docsRead); e != nil {
		return errors.Wrap(e, "sync failed")
	}
	updated, err := r.upgradeSchema(ctx)
	if err != nil {
		return errors.Wrap(err, "schema upgrade failed")
	}
	if updated {
		fmt.Printf("Documents were updated\n")
		if e := r.doSync(ctx, rdb, udbName, &docsWritten, &docsRead); e != nil {
			return errors.Wrap(e, "resync failed")
		}
	}
	log.Debugf("Synced %d docs from server, %d to server\n", docsRead, docsWritten)
	return nil
}
func ( r * Repo ) Sync ( ctx context . Context ) error { u , err := r . CurrentUser ( ) if err != nil { return err } udbName := " " + u rdb := r . remoteDSN ( udbName ) var docsWritten , docsRead int32 if e := r . doSync ( ctx , rdb , udbName , & docsWritten , & docsRead ) ; e != nil { return errors . Wrap ( e , " " ) } updated , err := r . upgradeSchema ( ctx ) if err != nil { return errors . Wrap ( err , " " ) } if updated { fmt . Printf ( " \n " ) if e := r . doSync ( ctx , rdb , udbName , & docsWritten , & docsRead ) ; e != nil { return errors . Wrap ( e , " " ) } } log . Debugf ( " \n " , docsRead , docsWritten ) return nil }
Sync performs a bi-directional sync.
Sync performs a bi - directional sync .