episode30

command
v0.0.0-...-c6e3130 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 29, 2022 License: Apache-2.0 Imports: 2 Imported by: 0

README

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

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL