db

package
v0.0.0-...-1d47ab2 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2024 License: AGPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrUnauthorized = errors.New("unauthorized")
)

Functions

func CreateSchema

func CreateSchema(db *bun.DB) error

create tables if they don't exist

Types

type Paste

type Paste struct {
	bun.BaseModel `bun:"table:pastes,alias:p"`
	ID            int64  `bun:"id,pk,autoincrement"`
	Content       string `bun:"content,notnull"`
	Language      string `bun:"language,notnull"`
	Expiry        string `bun:"expiry,notnull"`
	Size          uint64 `bun:"size"`
}

func CreatePaste

func CreatePaste(db *bun.DB, user *User, content string, lang string, expiry string, size uint64) (*Paste, error)

create paste

func GetPaste

func GetPaste(db *bun.DB, id int) (*Paste, error)

type SshKey

type SshKey struct {
	Fingerprint string `bun:"user_id"`
	Type        string `bun:"key,notnull"`
}

type User

type User struct {
	bun.BaseModel `bun:"table:users,alias:u"`

	ID         int64    `bun:"id,pk,autoincrement"`
	Name       string   `bun:"name,notnull,unique"`
	SshKeys    []SshKey `bun:"ssh_keys,type:jsonb"`
	Pastes     []int64  `bun:"pastes,type:jsonb"`
	PastesSize uint64   `bun:"pastes_size"`
}

func GetUser

func GetUser(db *bun.DB, sess ssh.Session) (*User, string, error)

get or create user

Jump to

Keyboard shortcuts

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