hashicorp / go-dbw

A simple package that encapsulates database operations.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

dbw package

Go Reference Go Report Card Go Coverage

dbw is a database wrapper that supports connecting and using any database with a GORM driver.

dbw is intended to completely encapsulate an application's access to its database with the exception of migrations. dbw is intentionally not an ORM and it removes typical ORM abstractions like "advanced query building", associations and migrations.

Of course you can use dbw for complicated queries, it's just that dbw doesn't try to reinvent SQL by providing some sort of pattern for building them with functions. Of course, dbw also provides lookup/search functions when you simply need to read resources from the database.

dbw strives to make CRUD for database resources fairly trivial for common use cases. It also supports an WithOnConflict(...) option for its RW.Create(...) function for complex scenarios. dbw also allows you to opt out of its CRUD functions and use exec, query and scan rows directly. You may want to carefully weigh when it's appropriate to use exec and query directly, since it's likely that each time you use them you're leaking a bit of your database layer schema into your application's domain.

About

A simple package that encapsulates database operations.

License:Mozilla Public License 2.0


Languages

Language:Go 61.0%Language:HTML 36.8%Language:Shell 1.5%Language:Makefile 0.6%Language:HCL 0.0%