airlift

package
v0.0.0-...-33a7bac Latest Latest
Warning

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

Go to latest
Published: Sep 14, 2020 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNotFound = errors.New("airlift: not found")

ErrNotFound is the error that is returned if the document being queried could not be found.

Functions

func Connect

func Connect(opts r.ConnectOpts) error

Connect connects to the database

func DeleteNote

func DeleteNote(id string) error

DeleteNote deletes a note.

func DeletePaper

func DeletePaper(id string) error

DeletePaper deletes a paper

func NewNote

func NewNote(title string) (string, error)

NewNote creates a new note and returns a unique human friendly ID. Data must be populated using UpdateNote.

func NewPaper

func NewPaper(title, subject string, year int) (string, error)

NewPaper creates a new paper and returns a unique human friendly ID. Data must be populated using UpdatePaper.

func SetNoteStar

func SetNoteStar(id, username string, starred bool) error

SetNoteStar sets the status of a note's star.

func SetPaperCompleted

func SetPaperCompleted(id, username string, completed bool) error

SetPaperCompleted marks a practice paper as completed for a user.

func UpdateNote

func UpdateNote(note Note) error

UpdateNote updates the information of a note.

func UpdatePaper

func UpdatePaper(paper Paper) error

UpdatePaper updates the information of a paper

func UpdatePassword

func UpdatePassword(username, hash string) error

UpdatePassword updates the password of a user with the given hash.

func UpdateScheduleByMatch

func UpdateScheduleByMatch(username string, schedule []string) error

UpdateScheduleByMatch updates a user's schedule by using prefix matching based on data from app4.

Types

type FullNote

type FullNote struct {
	Note
	UploaderName string `gorethink:"uploader_name"`
	SubjectName  string `gorethink:"subject_name"`
}

FullNote represents a note with some additional data.

func GetFullNote

func GetFullNote(id, username string) (FullNote, error)

GetFullNote returns a note and some additional data given its ID.

type FullPaper

type FullPaper struct {
	Paper
	UploaderName string `gorethink:"uploader_name"`
	SubjectName  string `gorethink:"subject_name"`
}

FullPaper represents a user uploaded paper with additional data

func GetCompletedPapers

func GetCompletedPapers(username string) ([]FullPaper, error)

GetCompletedPapers returns the papers completed by a user.

func GetFullPaper

func GetFullPaper(id, username string) (FullPaper, error)

GetFullPaper returns the paper with additional data uploaded by a user.

func GetUploadedPapers

func GetUploadedPapers(username string) ([]FullPaper, error)

GetUploadedPapers returns the papers uploaded by a user.

type FullSubject

type FullSubject struct {
	Subject
	Notes  []Note  `gorethink:"notes"`
	Papers []Paper `gorethink:"papers"`
}

FullSubject represents a subject along with notes and practice exams.

func GetFullSubject

func GetFullSubject(id, username string) (FullSubject, error)

GetFullSubject returns a subject along with its notes ordered by stars and papers ordered by publication year.

type Note

type Note struct {
	ID          string    `gorethink:"id"`
	Title       string    `gorethink:"title"`
	Subject     string    `gorethink:"subject"`
	Author      string    `gorethink:"author"`
	Uploader    string    `gorethink:"uploader"`
	Public      bool      `gorethink:"public"`
	Stars       []string  `gorethink:"stars"`
	Size        uint64    `gorethink:"size,omitempty"`
	HasStarred  bool      `gorethink:"has_starred,omitempty"`
	NumStars    int       `gorethink:"num_stars,omitempty"`
	UpdatedTime time.Time `gorethink:"updated_time,omitempty"`
	UploadTime  time.Time `gorethink:"upload_time,omitempty"`
}

Note represents a user uploaded note file.

func GetNote

func GetNote(id string) (Note, error)

GetNote returns a note given its ID.

func GetStarredNotes

func GetStarredNotes(username string) ([]Note, error)

GetStarredNotes returns the notes starred by a user.

func GetUploadedNotes

func GetUploadedNotes(username string) ([]Note, error)

GetUploadedNotes returns the notes uploaded by a user.

type Paper

type Paper struct {
	ID            string    `gorethink:"id"`
	Title         string    `gorethink:"title"`
	Year          int       `gorethink:"year"`
	Subject       string    `gorethink:"subject"`
	Author        string    `gorethink:"author"`
	Public        bool      `gorethink:"public"`
	Completed     []string  `gorethink:"completed"`
	Uploader      string    `gorethink:"uploader"`
	SolutionsSize uint64    `gorethink:"solutions_size,omitempty"`
	SourceSize    uint64    `gorethink:"source_size,omitempty"`
	QuestionsSize uint64    `gorethink:"questions_size,omitempty"`
	HasCompleted  bool      `gorethink:"has_completed,omitempty"`
	NumCompleted  int       `gorethink:"num_completed,omitempty"`
	UpdatedTime   time.Time `gorethink:"updated_time,omitempty"`
	UploadTime    time.Time `gorethink:"upload_time,omitempty"`
}

Paper represents a user uploaded paper

func GetPaper

func GetPaper(id string) (Paper, error)

GetPaper returns a paper given its ID

type Schedule

type Schedule []Subject

Schedule represents the schedule for a user.

func GetAlphaScheduleFor

func GetAlphaScheduleFor(user User) (Schedule, error)

GetAlphaScheduleFor returns the schedule for a user sorted by alphabetical order for use in selections.

func GetScheduleFor

func GetScheduleFor(user User) (Schedule, error)

GetScheduleFor returns the schedule for a user.

type Subject

type Subject struct {
	ID       string    `gorethink:"id"`
	Name     string    `gorethink:"name"`
	Match    string    `gorethink:"match"`
	ExamTime time.Time `gorethink:"exam_time"`
}

Subject represents a subject and its information.

func AllSubjects

func AllSubjects() ([]Subject, error)

AllSubjects returns all of the subjects in the database in alphabetical order.

func GetSubject

func GetSubject(id string) (Subject, error)

GetSubject returns the basic information of a subject.

type User

type User struct {
	Name        string   `gorethink:"name"`
	Username    string   `gorethink:"username"`
	Email       string   `gorethink:"email"`
	Password    string   `gorethink:"password,omitempty"`
	Schedule    []string `gorethink:"schedule,omitempty"`
	RawSchedule []string `gorethink:"raw_schedule,omitempty"`
}

User represents a user.

func GetUser

func GetUser(username string) (User, error)

GetUser returns the user data of a user.

Jump to

Keyboard shortcuts

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