Categorygithub.com/builtinx/pop
modulepackage
4.11.6+incompatible
Repository: https://github.com/builtinx/pop.git
Documentation: pkg.go.dev

# README

GoDoc Build Status

POP

A Tasty Treat For All Your Database Needs

So what does Pop do exactly? Well, it wraps the absolutely amazing https://github.com/jmoiron/sqlx library. It cleans up some of the common patterns and work flows usually associated with dealing with databases in Go.

Pop makes it easy to do CRUD operations, run migrations, and build/execute queries.

Pop, by default, follows conventions that were influenced by the ActiveRecord Ruby gem. What does this mean?

  • Tables must have an "id" column and a corresponding "ID" field on the struct being used.
  • If there is a timestamp column named created_at, and a CreatedAt time.Time attribute on the struct, it will be set with the current time when the record is created.
  • If there is a timestamp column named updated_at, and a UpdatedAt time.Time attribute on the struct, it will be set with the current time when the record is updated.
  • Default database table names are lowercase, plural, and underscored versions of the struct name. Examples: User{} is "users", FooBar{} is "foo_bars", etc...

Want to know more? Take a look at the documentation!

Documentation

Please visit http://gobuffalo.io for the latest documentation, examples, and more.

Quick Start

Shoulders of Giants

Pop would not be possible if not for all of the great projects it depends on. Please see SHOULDERS.md to see a list of them.

Contributing

First, thank you so much for wanting to contribute! It means so much that you care enough to want to contribute. We appreciate every PR from the smallest of typos to the be biggest of features.

To contribute, please read the contribution guidelines: CONTRIBUTING

# Packages

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
You can use the "packr2 clean" command to clean up this, and any other packr generated files.
No description provided by the author
No description provided by the author

# Functions

AddLookupPaths add paths to the current lookup paths list.
Connect takes the name of a connection, default is "development", and will return that connection from the available `Connections`.
CreateDB creates a database, given a connection definition.
DialectSupported checks support for the given database dialect.
DropDB drops an existing database, given a connection definition.
IsZeroOfUnderlyingType will check if the value of anything is the equal to the Zero value of that type.
LoadConfigFile loads a POP config file from the configured lookup paths.
LoadFrom reads a configuration from the reader and sets up the connections.
LookupPaths returns the current configuration lookup paths.
MigrationContent returns the content of a migration.
MigrationCreate writes contents for a given migration in normalized files.
NewConnection creates a new connection, and sets it's `Dialect` appropriately based on the `ConnectionDetails` passed into it.
NewFileMigrator for a path and a Connection.
NewMigrationBox from a packr.Box and a Connection.
NewMigrator returns a new "blank" migrator.
NewPaginator returns a new `Paginator` value with the appropriate defaults set.
NewPaginatorFromParams takes an interface of type `PaginationParams`, the `url.Values` type works great with this interface, and returns a new `Paginator` based on the params or `PaginatorPageKey` and `PaginatorPerPageKey`.
ParseConfig reads the pop config from the given io.Reader and returns the parsed ConnectionDetails map.
ParseMigrationFilename parses a migration filename.
Q will create a new "empty" query from the current connection.
SetLogger overrides the default logger.

# Variables

AvailableDialects lists the available database dialects.
Color mode, to toggle colored logs.
ConfigName is the name of the YAML databases config file.
Connections contains all available connections.
Debug mode, to toggle verbose log traces.
ErrConfigFileNotFound is returned when the pop config file can't be found, after looking for it.
Log defines the pop logger.
PaginatorPageKey is the query parameter holding the current page index.
PaginatorPerPageDefault is the amount of results per page.
PaginatorPerPageKey is the query parameter holding the amount of results per page to override the default one.

# Structs

Connection represents all necessary details to talk with a datastore.
ConnectionDetails stores the data needed to connect to a datasource.
FileMigrator is a migrator for SQL and Fizz files on disk at a specified path.
GroupClause holds the field to apply the GROUP clause on.
HavingClause defines a condition and its arguments for a HAVING clause.
Match holds the information parsed from a migration filename.
Migration handles the data for a given database migration.
MigrationBox is a wrapper around packr.Box and Migrator.
Migrator forms the basis of all migrations systems.
Model is used throughout Pop to wrap the end user interface that is passed in to many functions.
Paginator is a type used to represent the pagination of records from the database.
Query is the main value that is used to build up a query to be executed against the `Connection`.
Tx stores a transaction with an ID to keep track.

# Interfaces

AfterCreateable callback will be called after a record is created in the database.
AfterDestroyable callback will be called after a record is destroyed in the database.
AfterFindable callback will be called after a record, or records, has been retrieved from the database.
AfterSaveable callback will be called after a record is either created or updated in the database.
AfterUpdateable callback will be called after a record is updated in the database.
BeforeCreateable callback will be called before a record is created in the database.
BeforeDestroyable callback will be called before a record is destroyed in the database.
BeforeSaveable callback will be called before a record is either created or updated in the database.
BeforeUpdateable callback will be called before a record is updated in the database.
PaginationParams is a parameters provider interface to get the pagination params from.
TableNameAble interface allows for the customize table mapping between a name and the database.
Value is the contents of a `Model`.

# Type aliases

Migrations is a collection of Migration.
ScopeFunc applies a custom operation on a given `Query`.