Reminder

package module
v0.0.0-...-42aed7a Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2014 License: MIT Imports: 6 Imported by: 2

README

Release Version Build Status Coverage Status Go Walker Documentation Licence

Reminder

Documentation

Index

Constants

View Source
const (
	//DefaultReturn is the default number of notes to return in a GET request
	DefaultReturn = 100
)

Variables

This section is empty.

Functions

func DeleteNote

func DeleteNote(rWriter http.ResponseWriter, req *http.Request, db *Statements)

DeleteNote completely removes a note from the database.

func GetActiveNotes

func GetActiveNotes(rWriter http.ResponseWriter, req *http.Request, db *Statements)

GetActiveNotes gets all active notes within the parameters provided. The request can contain a JSON key-value pair of the following: startNumber: the number of results to skip before returning new results (used for pagination)

defaults to 0

numberToReturn: the amount of notes you want returned in one pass.

defaults to DefaultReturn

func NewNote

func NewNote(rWriter http.ResponseWriter, req *http.Request, db *Statements)

NewNote creates a note in the system. The request should contain a JSON representation of a note.

This will return a 200 status along with the fully completed note in the response.

If an error occurs a 4xx or 5xx status will be returned along with more information about the error.

Types

type Note

type Note struct {
	ID          int64     `json:"ID"`          //Must be globally unique
	StartDate   time.Time `json:"startDate"`   //Used for recurring notes
	DueDate     time.Time `json:"dueDate"`     //Exact time the Note is Due
	NextDueDate time.Time `json:"nextDueDate"` //Used for recurring notes
	Done        bool      `json:"done"`        //true == completed
	Text        string    `json:"text"`        //The note contents/text
}

Note holds a single note. For one-time notes, DueDate and NoteText need to be set.If Done is set to true then the note has been "completed". The program should never automatically mark a note as completed, no matter how far past due.

Recurring Notes: Set the DueDate for the next time the note will occur (if every week then set the due date to one week from now), and NextDueDate for the following time the note will occur (if every week thenset this to one week after the DueDate) When the note is retrieved the system should check if the DueDate has passed AND the note is Done. If those are true then create a new Note with a DueDate of the current note's NextDueDate, and a StartDate of the current note's DueDate.

If a `StartDate` is set, then the note should not display to the user until the `StartDate` has passed.

func CreateNoteFromReader

func CreateNoteFromReader(reader io.Reader) (*Note, error)

CreateNoteFromReader creates a new note from an io.Reader which has a JSON string.

type Statements

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

Statements is a container struct for the Database. It holds the connection to the DB as well as all prepared satements used throughout the application.

func PrepareStatements

func PrepareStatements(sqlDBHandle *sql.DB) (*Statements, error)

PrepareStatements prepares all SQL queries that will be used throughout the application.

func (*Statements) CreateNote

func (database *Statements) CreateNote(note *Note) error

CreateNote adds a new note to the system. This function modifies the given Note to add the ID returned from the database

func (*Statements) DeleteNote

func (database *Statements) DeleteNote(note *Note) error

DeleteNote completely removes a note from the database. the passed note should not be used after this function

func (*Statements) GetActiveNotes

func (database *Statements) GetActiveNotes(startNumber int, numberToReturn int) ([]*Note, error)

GetActiveNotes gets all current (not done, and past their start date) notes.

func (*Statements) RetrieveNote

func (database *Statements) RetrieveNote(ID int64) (*Note, error)

RetrieveNote gets a single note from the database based on ID

func (*Statements) UpdateNote

func (database *Statements) UpdateNote(note *Note) error

UpdateNote updates a note already in the database. note requires a good ID at minimum.

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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