Documentation ¶
Overview ¶
Package dynamodb is responsible for connections and data manipulation on dynamodb
Index ¶
- func CreateDatabase(databaseConfig model.Database) (abstraction.Database, error)
- func CreateTestDatabase() abstraction.Database
- func ValidateConfig(config model.Database) error
- type Database
- func (db *Database) CleanUpStaleData(target global.CleanupType, timeout int64) error
- func (db *Database) CleanupDeleted(olderThan time.Time) error
- func (db *Database) CleanupUnconfirmed(olderThan time.Time) error
- func (db *Database) CreateComment(body string, author string, path string, confirmed bool, replyTo *uuid.UUID) (*uuid.UUID, error)
- func (db *Database) CreateThread(path string) (*uuid.UUID, error)
- func (db *Database) DeleteComment(id uuid.UUID) error
- func (d *Database) DeleteTables() error
- func (db *Database) GetAllComments() (comments []model.Comment, err error)
- func (db *Database) GetAllThreads() (threads []model.Thread, err error)
- func (db *Database) GetComment(id uuid.UUID) (comment model.Comment, err error)
- func (db *Database) GetCommentsByThread(path string) (comments []model.Comment, err error)
- func (db *Database) GetDatabaseDialect() string
- func (db *Database) GetThread(path string) (thread model.Thread, err error)
- func (db *Database) GetUnderlyingStruct() interface{}
- func (db *Database) HardDeleteComment(commentId uuid.UUID) error
- func (db *Database) ImportData(pathToDump string) error
- func (db *Database) InitializeDatabase() error
- func (db *Database) RestoreDeletedComment(id uuid.UUID) error
- func (db *Database) UpdateComment(id uuid.UUID, body, author string, confirmed bool) error
- func (d *Database) WipeOutData() error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateDatabase ¶
func CreateDatabase(databaseConfig model.Database) (abstraction.Database, error)
CreateDatabase creates a database instance from the given config
func CreateTestDatabase ¶
func CreateTestDatabase() abstraction.Database
CreateTestDatabase creates a database instance for testing locally. It creates tables with UUID prefix, so should be safe to use even if tests are run in parallel.
func ValidateConfig ¶
ValidateConfig validates the config for sqlite
Types ¶
type Database ¶
Database is a database instance for sqlite
func (*Database) CleanUpStaleData ¶
func (db *Database) CleanUpStaleData(target global.CleanupType, timeout int64) error
CleanUpStaleData removes the stale data from the database
func (*Database) CleanupDeleted ¶
CleanupDeleted removes the deleted comments that are older than the given time
func (*Database) CleanupUnconfirmed ¶
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 ¶
CreateThread takes the thread path and creates it in the database
func (*Database) DeleteComment ¶
DeleteComment soft-deletes the comment by id and all the replies to it
func (*Database) DeleteTables ¶
DeleteTables deletes the thread and comment tables in the database if the database is a test one
func (*Database) GetAllComments ¶
GetAllComments gets all the comments found in the database
func (*Database) GetAllThreads ¶
GetAllThreads gets all the threads found in the database
func (*Database) GetComment ¶
GetComment gets comment by id
func (*Database) GetCommentsByThread ¶
GetCommentsByThread gets all the comments by thread path
func (*Database) GetDatabaseDialect ¶
GetDatabaseDialect returns the current database dialect
func (*Database) GetUnderlyingStruct ¶
func (db *Database) GetUnderlyingStruct() interface{}
GetUnderlyingStruct returns the underlying database struct for the driver
func (*Database) HardDeleteComment ¶
HardDeleteComment permanently deletes the comment from a database.
func (*Database) ImportData ¶
ImportData performs the data import for the given driver
func (*Database) InitializeDatabase ¶
InitializeDatabase runs the queries for an initial database seed
func (*Database) RestoreDeletedComment ¶
RestoreDeletedComment restores the soft-deleted comment
func (*Database) UpdateComment ¶
UpdateComment updatesComment comment by id
func (*Database) WipeOutData ¶
WipeOutData deletes all the threads and comments in the database if the database is a test one