Getting Started
CLI
Request handling
- Routing
- Action Controller
- Resources
- Context
- Request Binding
- Middleware
- Error Handling
- Sessions
- Cookies
Frontend
Database
- Getting started with Pop
- Soda CLI
- Database Configuration
- Buffalo Integration
- Models
- Generators
- Migrations
- Fizz
- Mutations
- Querying
- Raw Queries
- Callbacks
- Scoping
- Associations and Relationships
- One to one associations
- One to many associations
Guides
- API Applications
- File Uploads
- Background Job Workers
- Mailers
- Tasks
- Local Authentication
- Third Party Authentication
- Events
- Go Modules
- Localization
- Logging
- Template Engines
- Testing
- Videos
Deploy
Getting started with Pop
Database
Getting Started with Pop
The pop package is included with Buffalo by default, but you can use it outside of Buffalo. It wraps the absolutely amazing https://github.com/jmoiron/sqlx library, 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 with basic ORM functionality, 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 aCreatedAt 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 aUpdatedAt 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…
Buffalo has a deep integration with Pop, and it’ll help you to generate all the stuff you need to get started. You can still use another package if you want, but you’ll be by yourself. :)
Supported Databases
Pop supports the following databases:
- PostgreSQL (>= 9.3)
- CockroachDB (>= 2.1.0)
- MySQL (>= 5.7)
- SQLite3 (>= 3.x)
Installation
$ go get github.com/gobuffalo/pop/...
Next Steps
- CLI Soda - Install the Soda CLI.
- Configuration - Configure your database connections.