postgres

package
v0.0.0-...-3859033 Latest Latest
Warning

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

Go to latest
Published: Jan 30, 2019 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	*sql.DB
	// contains filtered or unexported fields
}

Client holds a link to the database and current implemented services.

func New

func New(dataSource string) (*Client, error)

New creates and returns a new Client struct.

func (*Client) LinkService

func (c *Client) LinkService() pinub.LinkService

LinkService returns the linked service.

func (*Client) UserService

func (c *Client) UserService() pinub.UserService

UserService returns the linked services.

type LinkService

type LinkService struct {
	Client *Client
}

LinkService represents a service for managing links.

func (s *LinkService) CreateLink(l *pinub.Link, u *pinub.User) error

CreateLink creates a new link for the given user. Four steps are necessary:

  1. check if link exists in table
  2. if no - create it
  3. check if user has a relation to link
  4. if no - create it

We can make a shortcut when link does not exists, we create it and also create the relation to the user.

func (s *LinkService) DeleteLink(l *pinub.Link, u *pinub.User) error

DeleteLink remove the link for the given user. Also removes the link when no user stored that link anymore.

func (s *LinkService) Links(u *pinub.User) ([]pinub.Link, error)

Links returns all links.

type UserService

type UserService struct {
	Client *Client
}

UserService represents a service for managing users.

func (*UserService) AddToken

func (s *UserService) AddToken(u *pinub.User) error

AddToken creates a new token for the given user object and sets the last active date to now.

func (*UserService) CreateUser

func (s *UserService) CreateUser(u *pinub.User) error

CreateUser stores the given user object on the users table. Does not create a new user when the given users email address is already in the database.

func (*UserService) DeleteUser

func (s *UserService) DeleteUser(u *pinub.User) error

DeleteUser removes the given user object from the users table.

func (*UserService) RefreshToken

func (s *UserService) RefreshToken(u *pinub.User) error

RefreshToken updates the last seen token of the user.

func (*UserService) UpdateUser

func (s *UserService) UpdateUser(u *pinub.User) error

UpdateUser updates the fields of the user object.

func (*UserService) User

func (s *UserService) User(email string) (*pinub.User, error)

User searches the users table for a user with the given email address.

func (*UserService) UserByToken

func (s *UserService) UserByToken(token string) (*pinub.User, error)

UserByToken queries the database for a user by the given token.

Jump to

Keyboard shortcuts

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