As of December 1st, 2019 Buffalo, and all related packages, require Go Modules and the use of the GOPATH is no longer supported.

Please see this blog post for more information https://blog.gobuffalo.io/the-road-to-1-0-requiring-modules-5672c6b015e5.

Raw Queries

Sometimes you'll need to write a custom query instead of letting Pop generate it for you. In this chapter, you'll learn how to write raw SQL queries using Pop.

Writing a Raw Query

Select

player := Player{}
q := db.RawQuery("SELECT * FROM players WHERE id = ?", 1)
err := q.Find(&player, id)

Update

err := db.RawQuery("UPDATE players SET instrument = ? WHERE id = ?", "guitar", 1).Exec()

Delete

err := db.RawQuery("DELETE FROM players WHERE id = ?", 1).Exec()

Tokens syntax

With RawQuery, you can continue to use the ? tokens to secure your input values. You don't need to use the token syntax for your underlying database.