Documentation ¶
Overview ¶
Package postgres defines Store, a Postgres client that partially implements the Store interface defined in "github.com/gokv/store".
Index ¶
- func WithCreateTable(db *sql.DB, tablename string) error
- type Option
- type Store
- func (s Store) Add(ctx context.Context, v json.Marshaler) (string, error)
- func (s Store) Close() (err error)
- func (s Store) Delete(ctx context.Context, k string) error
- func (s Store) Get(ctx context.Context, k string, v json.Unmarshaler) (bool, error)
- func (s Store) GetAll(ctx context.Context, c store.Collection) error
- func (s Store) Ping(ctx context.Context) error
- func (s Store) Set(ctx context.Context, k string, v json.Marshaler) error
- func (s Store) Update(ctx context.Context, k string, v json.Marshaler) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store holds the SQL statements prepared against a Postgresql table. Initialise with New.
func New ¶
New creates a table of name tablename if it does not exist, and prepares statements against it. The table has two columms: "k" is the TEXT primary key and "v" is a JSONb column holding the values.
func (Store) Add ¶
Add persists a new object and returns its unique UUIDv4 key. Err is non-nil in case of failure.
func (Store) Close ¶
Close releases the resources associated with the Store. Returns the first error encountered while closing the prepared statements.
func (Store) Get ¶
Get retrieves a new item by key and unmarshals it into v, or returns false if not found. Err is non-nil in case of failure.