document

package
v0.0.0-...-9cc5bb4 Latest Latest
Warning

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

Go to latest
Published: Apr 5, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

The package works on 2 tables on an SQLite database.

The names of the tables are:

  • Users
  • Userdata

The definitions of the tables are:

    CREATE TABLE Users (
        ID INTEGER PRIMARY KEY,
        Username TEXT
    );

    CREATE TABLE Userdata (
        UserID INTEGER NOT NULL,
        Name TEXT,
        Surname TEXT,
        Description TEXT
    );
	This is rendered as code

This is not rendered as code

Index

Constants

This section is empty.

Variables

View Source
var (
	Filename = ""
)

This global variable holds the SQLite3 database filepath

Filename: Is the filepath to the database file

Functions

func AddUser

func AddUser(d Userdata) int

AddUser adds a new user to the database

Returns new User ID -1 if there was an error

func DeleteUser

func DeleteUser(id int) error

DeleteUser deletes an existing user if the user exists. It requires the User ID of the user to be deleted.

It returns error

func UpdateUser

func UpdateUser(d Userdata) error

UpdateUser() is for updating an existing user given a Userdata structure. The user ID of the user to be updated is found inside the function.

Types

type Userdata

type Userdata struct {
	ID          int
	Username    string
	Name        string
	Surname     string
	Description string
}

The Userdata structure is for holding full user data from the Userdata table and the Username from the Users table

func ListUsers

func ListUsers() ([]Userdata, error)

ListUsers() lists all users in the database.

Returns a slice of Userdata to the calling function.

Notes

Bugs

  • Function ListUsers() not working as expected

  • Function AddUser() is too slow

Jump to

Keyboard shortcuts

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