Skip to content

Instantly share code, notes, and snippets.

@hugmouse
Created December 9, 2019 14:36
Show Gist options
  • Save hugmouse/8967d43355143447f6f284a18b707888 to your computer and use it in GitHub Desktop.
Save hugmouse/8967d43355143447f6f284a18b707888 to your computer and use it in GitHub Desktop.
Easy way to copy one EasyDB to another EasyDB
package easyDBCopy
import (
easy "github.com/EasyDB-io/Golang/client"
)
type DB struct {
database string
token string
}
func (d *DB) copyAllToDB(database string, token string) (err error) {
var (
list map[string]interface{}
)
dbFrom := easy.Connect(d.database, d.token)
dbTo := easy.Connect(database, token)
list, err = dbFrom.List()
if err != nil {
return err
}
for key, value := range list {
err = dbTo.Put(key, value)
if err != nil {
return err
}
}
return nil
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment