sqlite06

package
v0.0.0-...-039cffb Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

It is highly recommended that each Go package you create has a block comment
preceding the package declaration that introduces developers to the package, and
also explains what the package does.

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
);

// BUG(1): Function ListUsers() not working as expected
// BUG(2): Function AddUser() is too slow

Index

Constants

This section is empty.

Variables

View Source
var (
	Filename = ""
)

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

func UpdateUser

func UpdateUser(d Userdata) error

UpdateUser is for updating an existing user

Types

type Userdata

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

Most of the time, you need as many structures as there are database tables, however, since this a light package, we can combine fields of Users and Userdata table in one struct

func ListUsers

func ListUsers() ([]Userdata, error)

Jump to

Keyboard shortcuts

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