db

package module
v0.0.7 Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2021 License: AGPL-3.0 Imports: 12 Imported by: 0

README

db

Database helper for blahcdn

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func PasswordHash

func PasswordHash(plaintext string) ([]byte, error)

func ValidateHash

func ValidateHash(payload []byte, plaintext string) bool

Types

type Database

type Database struct {
	Client *ent.Client
}

func Connect

func Connect(ctx context.Context, url string) (*Database, error)

func (*Database) AuthorizeUser

func (d *Database) AuthorizeUser(ctx context.Context, username string, plaintext string) (bool, error)

func (*Database) CreateUser

func (d *Database) CreateUser(ctx context.Context, data *User) (*ent.User, error)

creates an user

func (*Database) CreateZone

func (d *Database) CreateZone(ctx context.Context, inp *Zone, ownerId int) (*ent.Zone, error)

creates a zone

func (*Database) QueryUser

func (d *Database) QueryUser(ctx context.Context, username string) (*ent.User, error)

func (*Database) QueryZone

func (d *Database) QueryZone(ctx context.Context, domain string) (*ent.Zone, error)

func (*Database) QueryZones

func (d *Database) QueryZones(ctx context.Context, username string) ([]*ent.Zone, error)

type User

type User struct {
	LowerUsername string
	DisplayName   string
	PasswordHash  []byte
	Username      string
	Email         string
	Zones         []Zone
}

type Zone

type Zone struct {
	Domain string
	Owner  User
}

Directories

Path Synopsis
ent

Jump to

Keyboard shortcuts

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