lib

package
v0.0.0-...-c1bcb0e Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2022 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InitDB

func InitDB(ctx context.Context, dataSourceName string) (*sql.DB, error)

InitDB creates a package global db connection from a database string.

func ParseAndStore

func ParseAndStore(ctx context.Context, db *sql.DB, u *User, buf []byte) error

ParseAndStore parses a tabe and stores to the db.

func TabCount

func TabCount(ctx context.Context, db *sql.DB) (int64, error)

TabCount counts the number of tabs in the db.

func UserCount

func UserCount(ctx context.Context, db *sql.DB) (int64, error)

UserCount returns a count of users.

func WithUser

func WithUser(ctx context.Context, u *User) context.Context

WithUser puts a user in the context.

Types

type Tab

type Tab struct {
	URL     string    `json:"url"`
	Title   string    `json:"title"`
	Favicon string    `json:"favicon"`
	Seen    time.Time `json:"seen"`
}

Tab is a single tab to archive.

type User

type User struct {
	ID         int64
	Name       string
	Email      string
	GoogleID   string
	CreatedAt  time.Time
	ModifiedAt time.Time
}

User is a single user.

func GetUser

func GetUser(ctx context.Context, db *sql.DB, authToken string) (*User, error)

GetUser gets a user from the database by token.

func UserFromContext

func UserFromContext(ctx context.Context) *User

UserFromContext finds the user from the context. This is usually inserted by WithUser.

func (*User) GetArchive

func (u *User) GetArchive(ctx context.Context, db *sql.DB) ([]*Tab, error)

GetArchive gets the most recent 1000 tabs.

Jump to

Keyboard shortcuts

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