An open API service indexing awesome lists of open source software.

https://github.com/daniilty/pgxquery

simple library for generating pgx queries from go struct
https://github.com/daniilty/pgxquery

Last synced: about 2 months ago
JSON representation

simple library for generating pgx queries from go struct

Awesome Lists containing this project

README

          

## pqxquery library

## Add to your project

```bash
$ go get github.com/daniilty/pgxquery
```
## Usage

```golang
type user struct {
pgxquery.TableName `db:"users"` // set here the name of related table

id int `db:"id,primarykey"` // primarykey tag used for updating by in update query
name string `db:"name,omitempty"` // omitempty is used for update queries(field will be omitted if zero value)
email string `db:"email"`
}

func insertUsers(...) {
q, _ := pgxquery.GenerateNamedUpdate(&user{
id: 1,
email: "pablo@gmail.com",
})

//will result in:
//update users set email=:email where id=:id;
}
```