Skip to content
Branch: master
Find file History
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
..
Failed to load latest commit information.
actions
assets
config
fixtures
grifts
locales
migrations
models
public
templates
.babelrc
.buffalo.dev.yml
.codeclimate.yml
.dockerignore
.gitignore
Dockerfile
Makefile
README.md
database.yml
docker-compose.yml
go.mod
go.sum
inflections.json
main.go
package.json
webpack.config.js
yarn.lock

README.md

Hooking your Buffalo Webapp to a Database

Go in 5 Minutes, episode 30.

Another episode in the Buffalo series! Last episode, we talked about building a "login with GitHub" button into your Buffalo app.

Today, we're gonna travel from that part of your app up to the database layer. If you're building a website, you'll almost certainly need a database to store information about your users. Luckily, Buffalo has great support for some of the most popular SQL databases.

This episode is tangentially related to #168

We're going to use the pop library -- which has great Buffalo integration -- to do some basic database integration in our app.

I'll briefly introduce the library and how to use it, then we'll go right to the code and see it in action!

Check out the screencast for more!

How To Run The App

This is a standard Buffalo app that requires a PostgresDB server to be running locally (on 127.0.0.1). Here's what you need to do to run the app.

First, run the database. We've provided a Docker Compose configuration file, so the easiest way to do this is to download the docker-compose binary and ensure you have the Docker server running. After you have those dependencies, run the database:

$ docker-compose -p ep30 up -d dev-env

This starts the database in a container in the background. Next, you should be all set to run the app:

$ buffalo dev

Now, you can access the app on http://localhost:3000.

When you're done, clean up the database with this command:

$ docker-compose -p ep30 down

Show Notes

You can’t perform that action at this time.