Create Client
- Go
- Java
- TypeScript
db.NewClient
with automatically read config by REX_ENV
, set to "development"
if missing.
c, err := db.NewClient()
c, err := db.NewClientWithEnv("development")
Client c = new Client();
Client c = new Client("development");
db.NewClient
with automatically read config by REX_ENV
, set to "development"
if missing.
const db = require("./db");
c = db.newClient();
c = db.newClientWithEnv("development");
Query
- Go
- Java
- TypeScript
The query methods support mapping columns into struct fileds via the db
struct tag.
var res struct {
Count int `db:"count"`
}
err := c.QueryOne("select count(id) from users").Scan(&res)
var users []struct {
ID int `db:"id"`
Name string `db:"name"`
}
err := c.Query("select id, name from users where id in (?)", []int{1, 2}).Scan(&users)
Exec
- Go
- Java
- TypeScript
affectedRows, err := c.Exec("delete from users where id != ?", 1)