sqlite

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: 11 Imported by: 0

Documentation

Overview

Package sqlite is responsible for sqlite database connections and initialization.

Index

Constants

This section is empty.

Variables

View Source
var SqliteQueries = []string{
	`CREATE TABLE IF NOT EXISTS Thread(
			Id BLOB PRIMARY KEY,
			CreatedAt TIMESTAMP DEFAULT CURRENT_TIMESTAMP not null,
			Path varchar(1024) not null UNIQUE
		)`,
	`CREATE TABLE IF NOT EXISTS Comment(
			Id BLOB PRIMARY KEY,
			ThreadId BLOB not null,
			Body text not null,
			Author varchar(255) not null,
			Confirmed bool not null default false,
			CreatedAt TIMESTAMP DEFAULT CURRENT_TIMESTAMP not null,
			ReplyTo BLOB default null,
			DeletedAt TIMESTAMP DEFAULT null,
			FOREIGN KEY(ThreadId) references Thread(Id)
		)`,
}

SqliteQueries represents a list of queries for initial table creation in sqlite

Functions

func CreateDatabase

func CreateDatabase(databaseConfig model.Database) (abstraction.Database, error)

CreateDatabase creates a database instance from the given config

func CreateDirectoryIfNotExists

func CreateDirectoryIfNotExists(path string, fs afero.Fs) error

CreateDirectoryIfNotExists checks for the given directory and if not found - creates it. Used for sqlite database initialization

func CreateTestDatabase

func CreateTestDatabase() abstraction.Database

CreateTestDatabase creates a test database in memory

func ValidateConfig

func ValidateConfig(config model.Database) error

ValidateConfig validates the config for sqlite

Types

This section is empty.

Jump to

Keyboard shortcuts

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