database

package
v0.0.0-...-ae8ac80 Latest Latest
Warning

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

Go to latest
Published: Jun 22, 2022 License: MPL-2.0 Imports: 9 Imported by: 0

README

Database

This directory contains the database support and migration logic. All models and database queries are centralized through this package.

Alternatives Considered

  • gorm ORM Framework. This framework could have reduced the amount of boilerplate code, but I was fighting it a bit with how I wanted to model the database schema.

TODO

  • Testing error cases outside of the happy path

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Database

type Database struct {
	// contains filtered or unexported fields
}

func Open

func Open() (*Database, error)

func (*Database) FindMessagesForUser

func (db *Database) FindMessagesForUser(user User, from time.Time, offset uint64, limit uint64) ([]Message, error)

func (*Database) FindMessagesForUserFromSender

func (db *Database) FindMessagesForUserFromSender(user User, sender User, from time.Time, offset uint64, limit uint64) ([]Message, error)

func (*Database) FindUser

func (db *Database) FindUser(username string) (*User, error)

func (*Database) InsertMessage

func (db *Database) InsertMessage(message Message) (Message, error)

func (*Database) InsertUser

func (db *Database) InsertUser(user User) (User, error)

type Message

type Message struct {
	UUID      uuid.UUID `json:"uuid"`
	CreatedAt time.Time `json:"createdAt"`
	Content   string    `json:"content"`
	Sender    User      `json:"sender"`
	Recipient User      `json:"recipient"`
}

type User

type User struct {
	UUID     uuid.UUID `json:"uuid"`
	Username string    `json:"username"`
}

Jump to

Keyboard shortcuts

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