Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrLocked = errors.New("note is read-only, unlock it first") ErrStale = errors.New("note changed elsewhere since it was read") )
Functions ¶
func Process ¶
Process changes the fields given of a note, used by PATCH /api/notes/{id} and `edit note`. The #tags of the content are the tags of the note, unless the tags are given: they then rewrite it. Pinning or locking alone leaves the note as it is, updated_at included. A locked note refuses content and tags, unless unlocked in the same call. TODO: the read is not locked, two edits within the same instant can both pass the UpdatedAt check; SELECT … FOR UPDATE if that happens.
Types ¶
type Input ¶
type Input struct {
ID string
Pinned *bool
Readonly *bool
Content *string
Tags *[]string
// UpdatedAt is the version the text was written over: content and tags are refused once the note changed since.
UpdatedAt *time.Time
// Restore is a version restored: the text it replaces is kept even within a session, it may be nowhere else.
Restore bool
}
Input has pointers to tell a field left out from an empty one: editnote replaces everything, so a change without tags must keep them, not clear them.
Click to show internal directories.
Click to hide internal directories.