Implementing the database layer

Now, we have to implement the functionality of our database layer.

In the previous chapter, we designed a database layer interface that defined all of the database operations we are expected to need. This is what it looked like:

type DBLayer interface {  GetAllProducts() ([]models.Product, error)  GetPromos() ([]models.Product, error)  GetCustomerByName(string, string) (models.Customer, error)  GetCustomerByID(int) (models.Customer, error)  GetProduct(int) (models.Product, error)  AddUser(models.Customer) (models.Customer, error)  SignInUser(username, password string) (models.Customer, error)  SignOutUserById(int) error  GetCustomerOrdersByID(int) ([]models.Order, error)}

In our project folder, let's create a new file ...

Get Hands-On Full Stack Development with Go now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.