Each user should have an independent collection of books. We'll associate books with a user and filter books being pulled from the database to match the corresponding user.
- [Larry] Hi, and welcome back.…In our last video, we enforced authentication…in our web application to prevent unknown users…from entering the site.…In this video, we'll associate books to users,…such that users can maintain a personal library.…We'll start by adding a user identification column…to the books table.…Then, we'll update our Go representation…of the book objects.…Finally, we'll update the database query to only fetch books…belonging to the current user.…Let's get started.…
We'll open a SQLite 3 console in our terminal…with our development database.…We want to add a new column to the books table.…We'll write the command…alter table books add column user varchar(255).…Although we could make this column…a true foreign key column, it's not necessary,…and version one of Go Gorp…does not offer full support for foreign keys.…With that finished, let's open the main.go file…and update our Go representation…by adding a User string field to the Books draft.…
Now, I need to update all of our CRUD calls.…Whenever we delete a Book, we want to make sure the Book…
Go is on the rise. This open-source programming language (created by Google!) comes with a strong and accessible standard library, and provides a growing ecosystem of tools, libraries, and frameworks that can help you build web applications fast. Go for Web Development gets you started with the language, opening with the classic "Hello world" exercise and culminating in a web application with a strongly designed database back end, useful middleware, UI with an intelligent search function, multi-user authentication, and more.
First, learn how to build a web server with Go's extensive standard library. Explore the concepts behind a single-page web application and learn how to create a dynamic user interface, manipulate a database, and use powerful encryption algorithms to implement an authentication system. Next, you'll incorporate more functionality by calling out to external libraries from the database. Finally, it all comes together into an optimized package you can deploy into the wild with Heroku.
- Creating a route in Go
- Using templates
- Building database connections
- Collecting data
- Using web middleware
- Using the Ace template engine
- Integrating HTTP routers like gorilla/mux
- Authenticating users
- Optimizing a Go codebase