sql

package
v0.0.0-...-ee3c536 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2019 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Schemas

func Schemas() []string

Schemas is a function that returns a slice of string that contains the create sql syntax

Types

type DB

type DB struct {
	Sqlx *sqlx.DB
}

DB uses the sqlx library to interact with our sql database.

func New

func New(dataSourceName string) (*DB, error)

New returns the pointer to sqlx.DB struct.

func (*DB) Create

func (db *DB) Create(dbName string)

Create creates the database if not exists.

func (*DB) Migrate

func (db *DB) Migrate()

Migrate migrates a table.

func (*DB) Use

func (db *DB) Use(dbName string)

Use selects the given database to operate with.

type Post

type Post struct {
	DB       *sqlx.DB
	PostSrvc *app.Post
}

Post implements the PostService interface

func (*Post) CreatePost

func (p *Post) CreatePost(post *app.Post) error

CreatePost ...

func (*Post) DeletePost

func (p *Post) DeletePost(id int64) error

DeletePost ...

func (*Post) Post

func (p *Post) Post(id int64) (*app.Post, error)

Post ...

func (*Post) Posts

func (p *Post) Posts() ([]*app.Post, error)

Posts ...

func (*Post) UpdatePost

func (p *Post) UpdatePost(post *app.Post) error

UpdatePost ...

type PostService

type PostService interface {
	app.PostService
}

PostService implements the app.UserService

func NewPostSQLService

func NewPostSQLService(db *sqlx.DB) PostService

NewPostSQLService returns the interface that implements the app.PostService

type User

type User struct {
	DB        *sqlx.DB
	UserSrvc  *app.User
	TokenAuth *jwtauth.JWTAuth
}

User implements the UserService interface

func (*User) CreateUser

func (u *User) CreateUser(user *app.User) error

CreateUser ...

func (*User) DeleteUser

func (u *User) DeleteUser(id int64) error

DeleteUser ...

func (*User) GenerateAuthToken

func (u *User) GenerateAuthToken(user *app.User) (string, error)

GenerateAuthToken ...

func (*User) GetUserPosts

func (u *User) GetUserPosts(userID int64) ([]*app.UserPosts, error)

GetUserPosts returns a slice to pointer of UserPosts.

func (*User) Login

func (u *User) Login(email, password string) (*app.User, error)

Login ...

func (*User) UpdateUser

func (u *User) UpdateUser(user *app.User) error

UpdateUser ...

func (*User) User

func (u *User) User(id int64) (*app.User, error)

User ...

func (*User) UserByEmail

func (u *User) UserByEmail(email string) (*app.User, error)

UserByEmail ...

func (*User) Users

func (u *User) Users() ([]*app.User, error)

Users ...

type UserService

type UserService interface {
	app.UserService
}

UserService implements the app.UserService

func NewUserSQLService

func NewUserSQLService(db *sqlx.DB, jwtService *jwtservice.JWT) UserService

NewUserSQLService returns the interface that implements the app.UserService

Jump to

Keyboard shortcuts

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