sqlite

package
v0.0.0-...-375f364 Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2022 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FormatLimitOffset

func FormatLimitOffset(limit, offset int) string

Types

type AuthService

type AuthService struct {
	// contains filtered or unexported fields
}

AuthService represents a service used to manage OAuth.

func NewAuthService

func NewAuthService(db *DB) *AuthService

NewAuthService returns a new instance of AuthService attached to db.

func (*AuthService) CreateAuth

func (s *AuthService) CreateAuth(ctx context.Context, auth *pa.Auth) error

CreateAuth creates a new auth obj if a user is attached, the auth obj is linked back to only an existing user, if not existing the user is created and the auth is attached. A sucessful call will return an auth with the auth.UserID != 0

func (*AuthService) DeleteAuth

func (s *AuthService) DeleteAuth(ctx context.Context, id int) error

DeleteAuth permanently deletes the auth specified by the id. attached user wont be removed.

func (*AuthService) FindAuthByID

func (s *AuthService) FindAuthByID(ctx context.Context, id int) (*pa.Auth, error)

FindAuthByID returns a auth based on the id. returns ENOTFOUND if the auth doesent exist.

func (*AuthService) FindAuths

func (s *AuthService) FindAuths(ctx context.Context, filter pa.AuthFilter) ([]*pa.Auth, int, error)

FindAuths returns a range of auth based on filter.

type BlogService

type BlogService struct {
	// contains filtered or unexported fields
}

BlogService represents a service used to manage blogs.

func NewBlogService

func NewBlogService(db *DB) *BlogService

NewBlogService returns a new instance of BlogService attached to db.

func (*BlogService) CreateBlog

func (s *BlogService) CreateBlog(ctx context.Context, blog *pa.Blog) error

CreateBlog creates a new blog. returns EUNAUTHORIZED if the user trying to create the blog isnt the admin user.

func (*BlogService) DeleteBlog

func (s *BlogService) DeleteBlog(ctx context.Context, id int) error

DeleteBlog permanently deletes the blog specified by id. returns EUNAUTHORIZED if the user trying to delete the blog isnt the admin user. returns ENOTFOUND if the blog doesent exist.

func (*BlogService) FindBlogByID

func (s *BlogService) FindBlogByID(ctx context.Context, id int) (*pa.Blog, error)

FindBlogByID returns a blog based on id. returns ENOTFOUND if the blog doesent exist.

func (*BlogService) FindBlogs

func (s *BlogService) FindBlogs(ctx context.Context, filter pa.BlogFilter) ([]*pa.Blog, int, error)

FindBlogs returns a range of blog based on filter.

func (*BlogService) UpdateBlog

func (s *BlogService) UpdateBlog(ctx context.Context, id int, update pa.BlogUpdate) (*pa.Blog, error)

UpdateBlog updates blog with id: id. returns EUNAUTHORIZED if the user trying to update the blog isnt the admin user. returns ENOTFOUND if the blog doesent exist.

type CommentService

type CommentService struct {
	// contains filtered or unexported fields
}

CommentService represents a service used to manage comments.

func NewCommentService

func NewCommentService(db *DB) *CommentService

NewCommentService returns a new instance of CommentService attached to db.

func (*CommentService) CreateComment

func (s *CommentService) CreateComment(ctx context.Context, comment *pa.Comment) error

CreateComment creates a new comment.

func (*CommentService) DeleteComment

func (s *CommentService) DeleteComment(ctx context.Context, id int) error

DeleteComment permanently deletes the comment specified by id. returns EUNAUTHORIZED if the user isnt trying to delete his own comment. returns ENOTFOUND if the comment doesent exist.

func (*CommentService) FindCommentByID

func (s *CommentService) FindCommentByID(ctx context.Context, id int) (*pa.Comment, error)

FindCommentByID returns a comment based on id. returns ENOTFOUND if the comment doesent exist.

func (*CommentService) FindComments

func (s *CommentService) FindComments(ctx context.Context, filter pa.CommentFilter) ([]*pa.Comment, int, error)

FindComments returns a range of comment based on filter.

func (*CommentService) UpdateComment

func (s *CommentService) UpdateComment(ctx context.Context, id int, update pa.CommentUpdate) (*pa.Comment, error)

UpdateComment updates comment with id: id. returns EUNAUTHORIZED if the user isnt trying to update isnt the admin user. returns ENOTFOUND if the comment doesent exist.

type DB

type DB struct {
	DSN string

	Now func() time.Time
	// contains filtered or unexported fields
}

func NewDB

func NewDB(dsn string) *DB

func (*DB) BeginTX

func (db *DB) BeginTX(ctx context.Context, opts *sql.TxOptions) (*Tx, error)

func (*DB) Close

func (db *DB) Close() error

func (*DB) MustBeginTX

func (db *DB) MustBeginTX(ctx context.Context, opts *sql.TxOptions) *Tx

testing only

func (*DB) Open

func (db *DB) Open() (err error)

type NullTime

type NullTime time.Time

func (*NullTime) Scan

func (n *NullTime) Scan(value interface{}) error

func (*NullTime) Value

func (n *NullTime) Value() (driver.Value, error)

type ProjectService

type ProjectService struct {
	// contains filtered or unexported fields
}

ProjectService represents a service used to manage projects.

func NewProjectService

func NewProjectService(db *DB) *ProjectService

NewProjectService returns a new instance of ProjectService attached to db.

func (*ProjectService) CreateOrUpdateProject

func (s *ProjectService) CreateOrUpdateProject(ctx context.Context, project *pa.Project) error

func (*ProjectService) DeleteProject

func (s *ProjectService) DeleteProject(ctx context.Context, name string) error

func (*ProjectService) FindProjectByID

func (s *ProjectService) FindProjectByID(ctx context.Context, id int) (*pa.Project, error)

func (*ProjectService) FindProjectByName

func (s *ProjectService) FindProjectByName(ctx context.Context, name string) (*pa.Project, error)

func (*ProjectService) FindProjects

func (s *ProjectService) FindProjects(ctx context.Context, filter pa.ProjectFilter) ([]*pa.Project, int, error)

type SubBlogService

type SubBlogService struct {
	// contains filtered or unexported fields
}

SubBlogService represents a service used to manage sub blogs.

func NewSubBlogService

func NewSubBlogService(db *DB) *SubBlogService

NewSubBlogService returns a new instance of SubBlogService attached to db.

func (*SubBlogService) CreateSubBlog

func (s *SubBlogService) CreateSubBlog(ctx context.Context, subBlog *pa.SubBlog) error

CreateSubBlog creates a new sub blog. returns EUNAUTHORIZED if the user trying to create the sub blog isnt the admin user.

func (*SubBlogService) DeleteSubBlog

func (s *SubBlogService) DeleteSubBlog(ctx context.Context, id int) error

DeleteSubBlog permanently deletes the sub blog specified by id. returns EUNAUTHORIZED if the user trying to delete the sub blog isnt the admin user. returns ENOTFOUND if the sub blog doesent exist.

func (*SubBlogService) FindSubBlogByID

func (s *SubBlogService) FindSubBlogByID(ctx context.Context, id int) (*pa.SubBlog, error)

FindSubBlogByID returns a sub blog based on id. returns ENOTFOUND if the sub blog doesent exist.

func (*SubBlogService) FindSubBlogs

func (s *SubBlogService) FindSubBlogs(ctx context.Context, filter pa.SubBlogFilter) ([]*pa.SubBlog, int, error)

FindSubBlogs returns a range of sub blog based on filter.

func (*SubBlogService) UpdateSubBlog

func (s *SubBlogService) UpdateSubBlog(ctx context.Context, id int, update pa.SubBlogUpdate) (*pa.SubBlog, error)

UpdateSubBlog updates sub blog with id: id. returns EUNAUTHORIZED if the user trying to update the sub blog isnt the admin user. returns ENOTFOUND if the sub blog doesent exist.

type SubscriptionService

type SubscriptionService struct {
	// contains filtered or unexported fields
}

SubscriptionService represents a serivce used to manage subscriptions.

func NewSubscriptionService

func NewSubscriptionService(db *DB) *SubscriptionService

NewSubscriptionService returns a new instance of SubscriptionService attached to db.

func (*SubscriptionService) CreateSubscription

func (s *SubscriptionService) CreateSubscription(ctx context.Context, subscription *pa.Subscription) error

CreateSubscription creates a new subscription and links it to the user.

func (*SubscriptionService) DeleteSubscription

func (s *SubscriptionService) DeleteSubscription(ctx context.Context, id int, topic string) error

DeleteSubscription permanently deletes the subscription only if the owner of the subscription is the user himself.

func (*SubscriptionService) FindSubscriptionByID

func (s *SubscriptionService) FindSubscriptionByID(ctx context.Context, id int, topic string) (*pa.Subscription, error)

FindSubscriptionByID returns a subscription based on the id and topic. returns ENOTFOUND if the subscription doesent exist.

func (*SubscriptionService) FindSubscriptions

func (s *SubscriptionService) FindSubscriptions(ctx context.Context, filter pa.SubscriptionFilter) ([]*pa.Subscription, int, error)

FindSubscriptions returns a range of subscriptions based on filter. Only returns subscriptions which the user owns.

type Tx

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

type UserService

type UserService struct {
	// contains filtered or unexported fields
}

UserService represents a service used to manage users.

func NewUserService

func NewUserService(db *DB) *UserService

NewUserService returns a new instance of UserService attached to db.

func (*UserService) CreateUser

func (s *UserService) CreateUser(ctx context.Context, user *pa.User) error

CreateUser creates a new user. To only be used in testing as users are created through the create auth process AuthService.CreateAuth() -> ./auth.go

func (*UserService) DeleteUser

func (s *UserService) DeleteUser(ctx context.Context, id int) error

DeleteUser permanently deletes the user specified by id. returns EUNAUTHORIZED if the user isnt trying to delete himself. returns ENOTFOUND if the user doesent exist.

func (*UserService) FindUserByID

func (s *UserService) FindUserByID(ctx context.Context, id int) (*pa.User, error)

FindUserByID returns a user based on id. returns ENOTFOUND if the user doesent exist.

func (*UserService) FindUsers

func (s *UserService) FindUsers(ctx context.Context, filter pa.UserFilter) ([]*pa.User, int, error)

FindUsers returns a range of user based on filter.

func (*UserService) UpdateUser

func (s *UserService) UpdateUser(ctx context.Context, id int, update pa.UserUpdate) (*pa.User, error)

UpdateUser updates user with id: id. returns EUNAUTHORIZED if the user isnt trying to update himself. returns ENOTFOUND if the user doesent exist.

Jump to

Keyboard shortcuts

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