Documentation
¶
Index ¶
- type Book
- func (book *Book) Backup(w io.Writer) error
- func (book *Book) Delete(ids ...int) error
- func (book *Book) Insert(notes ...*Note) error
- func (book *Book) Len() int
- func (book *Book) MarshalJSON() ([]byte, error)
- func (book *Book) Restore(r io.Reader) error
- func (book *Book) Select(ids ...int) ([]*Note, error)
- func (book *Book) UnmarshalJSON(data []byte) error
- func (book *Book) Update(notes ...*Note) error
- type ErrNotFound
- type Note
- func (note *Note) CreatedAt() time.Time
- func (note *Note) ID() int
- func (note *Note) IsValid() bool
- func (note *Note) MarshalJSON() ([]byte, error)
- func (note *Note) Short(i int) string
- func (note *Note) String() string
- func (note *Note) UnmarshalJSON(data []byte) error
- func (note *Note) UpdatedAt() time.Time
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Book ¶
type Book struct {
Logger io.Writer // Logger for verbose logging
// contains filtered or unexported fields
}
A Book allows for management, such as inserting, updating, and deleting notes.
func (*Book) MarshalJSON ¶
MarshalJSON returns the JSON encoding of the book.
func (*Book) Restore ¶
Restore restores the book from the provided reader. The reader should contain a JSON-encoded book.
func (*Book) Select ¶
Select returns the notes that match the given ids. If no ids are given, all notes are returned.
func (*Book) UnmarshalJSON ¶
UnmarshalJSON parses the JSON-encoded data and stores the result in the book.
type ErrNotFound ¶
type ErrNotFound int
ErrNotFound is returned when a note is not found.
func (ErrNotFound) Error ¶
func (e ErrNotFound) Error() string
type Note ¶
type Note struct {
Body string `json:"body,omitempty"` // The body of the note.
// contains filtered or unexported fields
}
A Note is a single entry in a book.
func (*Note) MarshalJSON ¶
MarshalJSON returns the JSON encoding of the note.
func (*Note) Short ¶
Short returns a truncated version of the note body. If the body is less than the specified length, the whole body is returned. Newlines are escaped. "\\n"
func (*Note) UnmarshalJSON ¶
UnmarshalJSON parses the JSON-encoded data and stores the result in the note.