db

package
v0.0.0-...-0bee801 Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2024 License: AGPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const Tables string = `` /* 1512-byte string literal not displayed */

Groups table contains data for group so it can be joined when called by the user files table contains all the metadata of the file and how many parts it may have, that total_parts is calculated by a function and doesn't care about the discord files. Parts table has all the parts that are uploaded by the UploadFiles function On the groups table, root group means if a group is related to some other group, TODO: add better names

Variables

View Source
var (
	DB *sql.DB
)

Functions

func GetPartIDs

func GetPartIDs(ctx context.Context, fileID int) ([]string, error)

gets all the fileparts for use by different function, it returns them in orders since discord uses a timestamp as id it works fine

func InitDatabase

func InitDatabase() error

InitDatabase initializes the database, creating necessary tables if they don't exist.

func RegisterFileEntry

func RegisterFileEntry(ctx context.Context, fileStructure *FilesLocal) (int64, error)

RegisterFileEntry adds a file entry to the files table in the database.

Types

type FilesDB

type FilesDB struct {
	ID int // Auto-incremented ID, PRIMARY KEY
	FilesLocal
}

FilesDB represents a file entry in the database, including its ID.

type FilesLocal

type FilesLocal struct {
	Name        string // Name of the file
	Total_parts int    // Number of parts the file is divided into
	Size        int64  // Size of the file
	Hash        string // Hash for verifying file integrity, on complete download user may check for hash match
	GroupID     int    // User may assign group to each file for future search commands, multiple files may belong to same group i.e. math books
}

FilesLocal represents a local file's metadata.

type Parts

type Parts struct {
	FileID int      // File ID that was registered earlier
	Parts  []string // The parts message IDs uploaded by the app.UploadFile() function
}

Used to register the file parts to the DB

func (*Parts) InsertParts

func (parts *Parts) InsertParts(ctx context.Context, data Parts) error

InsertParts Allows for registering the uploaded files in the database

(data Parts) is the []string of data of registered files

Jump to

Keyboard shortcuts

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