Easydb
A library on go to access easily some databases. The main rule of this library is to follow a unique interface for all
databases that we implemented. So, you will only need to know one library (easydb) for accessing many databases.
Supported databases
Getting started
Download
go get github.com/ednailson/easydb-go
Database Interface
The main principle of the library is the database interface.
Every implemented database follows this interface after created.
There is a New(...params)
function for every database, and all of them there is
their own config struct param. This function will return a database interface,
so after that it will be the same usage for every database.
Check how to use it below.
Usage
Creating a database
We will create a mongoDB instance right now but you can created an instance
of any easydb implemented database.
config := mongo.Config {
Host: "mongodb.service.com.br",
Port: 27017,
Database: "easydb_test",
Username: "root",
Password: "dummyPass",
}
db, err := mongo.NewDatabase(config)
Creating a table/collection
table, err := db.Table("easydb-table-example")
Now you can write or read from this table
Writing on a table/collection
writer := table.Writer()
writer.Save(`{"data": "your data"}`)
Reading on a table/collection
reader := table.Reader()
reader.Read("document-id")
Developer
Junior