Created
December 9, 2019 14:36
-
-
Save hugmouse/8967d43355143447f6f284a18b707888 to your computer and use it in GitHub Desktop.
Easy way to copy one EasyDB to another EasyDB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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