patchnote

package
v0.0.0-...-4d14c86 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2026 License: MIT Imports: 10 Imported by: 0

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

func Process(ctx context.Context, db bun.IDB, input Input) *run

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.

Jump to

Keyboard shortcuts

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