sqlxDriver

package
v0.0.0-...-09e72e1 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2021 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package sqlxDriver allows for data manipulation through the github.com/jmoiron/sqlx package.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Database

type Database struct {
	DB      *sqlx.DB
	Queries []string
	Dialect string
	IsTest  bool
}

Database is a database instance for sqlx

func (*Database) CleanUpStaleData

func (db *Database) CleanUpStaleData(target global.CleanupType, timeout int64) error

CleanUpStaleData removes the stale data from the database

func (*Database) CleanupDeleted

func (db *Database) CleanupDeleted(olderThan time.Time) error

CleanupDeleted removes the deleted comments that are older than the given time

func (*Database) CleanupUnconfirmed

func (db *Database) CleanupUnconfirmed(olderThan time.Time) error

CleanupUnconfirmed removes the unconfirmed comments that are older than the given time

func (*Database) CreateComment

func (db *Database) CreateComment(body string, author string, path string, confirmed bool, replyTo *uuid.UUID) (*uuid.UUID, error)

CreateComment takes in a body, author, and path and creates a comment for the given thread. If thread does not exist, it creates one

func (*Database) CreateThread

func (db *Database) CreateThread(path string) (*uuid.UUID, error)

CreateThread takes the thread path and creates it in the database

func (*Database) DeleteComment

func (db *Database) DeleteComment(id uuid.UUID) error

DeleteComment soft-deletes the comment by id and all the replies to it

func (*Database) GetAllComments

func (db *Database) GetAllComments() (comments []model.Comment, err error)

GetAllComments gets all the comments found in the database

func (*Database) GetAllThreads

func (db *Database) GetAllThreads() (threads []model.Thread, err error)

GetAllThreads gets all the threads found in the database

func (*Database) GetComment

func (db *Database) GetComment(id uuid.UUID) (comment model.Comment, err error)

GetComment gets comment by id

func (*Database) GetCommentsByThread

func (db *Database) GetCommentsByThread(path string) (comments []model.Comment, err error)

GetCommentsByThread gets all the comments by thread path

func (*Database) GetDatabaseDialect

func (db *Database) GetDatabaseDialect() string

GetDatabaseDialect returns the current database dialect

func (*Database) GetThread

func (db *Database) GetThread(path string) (thread model.Thread, err error)

GetThread takes the thread path and fetches it from the database

func (*Database) GetUnderlyingStruct

func (db *Database) GetUnderlyingStruct() interface{}

GetUnderlyingStruct returns the underlying database struct for the driver

func (*Database) HardDeleteComment

func (db *Database) HardDeleteComment(commentId uuid.UUID) error

HardDeleteComment permanently deletes the comment from a database.

func (*Database) ImportData

func (db *Database) ImportData(pathToDump string) error

ImportData performs the data import for the given driver

func (*Database) InitializeDatabase

func (db *Database) InitializeDatabase() error

InitializeDatabase runs the queries for an initial database seed

func (*Database) RestoreDeletedComment

func (db *Database) RestoreDeletedComment(id uuid.UUID) error

RestoreDeletedComment restores the soft-deleted comment

func (*Database) UpdateComment

func (db *Database) UpdateComment(id uuid.UUID, body, author string, confirmed bool) error

UpdateComment updatesComment comment by id

func (*Database) WipeOutData

func (db *Database) WipeOutData() error

WipeOutData deletes all the threads and comments in the database if the database is a test one

Directories

Path Synopsis
Package mysql is responsible for mysql database connections and initialization.
Package mysql is responsible for mysql database connections and initialization.
Package postgres is responsible for postgres database connections and initialization.
Package postgres is responsible for postgres database connections and initialization.
Package sqlite is responsible for sqlite database connections and initialization.
Package sqlite is responsible for sqlite database connections and initialization.

Jump to

Keyboard shortcuts

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