Seitenleiste

Zeigt die mobile Seitenleiste an.

Doku durchsuchen

Doku durchsuchen

The example
The example
What is in it
What it has, exactly
Making it yours
How it is built
How it is built
A page declares what it needs
Running it
The API of charter-example
The API of charter-example
Operations
Ways in
GET /api/hello
GET /api/notes
POST /api/notes
GET /api/notes/watch
DELETE /api/notes/{id}
GET /api/people
PUT /api/people/{id}/role
Types
ErrorDetail
ErrorModel
Note
Person
The database
The database
Tables
notes
activity
attachments
users
passkeys
tokens
ceremonies
Statements
What the Worker is bound to
What the Worker is bound to
Anmelden

Zeitzone und Uhrzeitformat

Datums- und Zeitangaben auf allen Seiten verwenden diese Einstellungen. „Automatisch“ verwendet die Zeitzone Ihres Browsers.

Wird geladen…

The database

Every table the app keeps, and every statement it runs on them.

Written by charter from db/schema.sql and db/queries.sql, the one place a table and a statement are written down: it is what the app has now, and changes when that does.

Tables

notes

ColumnType
idINTEGERthe key
bodyTEXT
author_idTEXTdefault ''Who wrote it: their id, empty for a program with one of the Worker's own tokens
authorTEXTdefault ''What they call themselves
created_atTEXTdefault CURRENT_TIMESTAMP

activity

ColumnType
idINTEGERthe key
kindTEXT
note_idINTEGERdefault 0
authorTEXTdefault ''
notesINTEGERdefault 0
created_atTEXTdefault CURRENT_TIMESTAMP

attachments

ColumnType
idINTEGERthe key
objectTEXT
nameTEXT
typeTEXT
sizeINTEGER
note_idINTEGERdefault 0
author_idTEXT
authorTEXT
created_atTEXTdefault CURRENT_TIMESTAMP

users

ColumnType
idTEXTthe key
nameTEXT
roleTEXT
created_atTEXTdefault CURRENT_TIMESTAMP
emailTEXTmay be empty (NULL)

passkeys

ColumnType
idTEXTthe key
user_idTEXT
credentialTEXT
created_atTEXTdefault CURRENT_TIMESTAMP
nameTEXTdefault ''
used_atTEXTmay be empty (NULL)

tokens

ColumnType
idINTEGERthe key
hashTEXT
user_idTEXT
kindTEXT
nameTEXTdefault ''
scopesTEXT
expires_atTEXTmay be empty (NULL)
created_atTEXTdefault CURRENT_TIMESTAMP

ceremonies

ColumnType
idTEXTthe key
dataTEXT
expires_atTEXT

Statements

Each is a function of the package db, with its arguments and its rows typed against the tables above. No statement is written anywhere else.

FunctionIt givesWhat it does
db.CreateNoteone row, or no such rowINSERT INTO notes (body, author_id, author) VALUES (?, ?, ?) RETURNING *
db.RemoveNoteone row, or no such rowRemoveNote takes a note away, and says which it was.
db.RemoveNotesByrowsRemoveNotesBy takes away everything someone wrote, and says which notes those were.
db.Noteone row, or no such rowNote is one note, by its id.
db.NotesBeforerowsNotesBefore is a page of notes, newest first, before a note id.
db.NotesAfterrowsNotesAfter is the notes after a note id, oldest first: the log a stream follows.
db.NewestNoteone row, or no such rowNewestNote is the id of the newest note, 0 if there is none.
db.NotesByrowsNotesBy is someone's notes, newest first: what they may attach a file to.
db.NotesReportone row, or no such rowNotesReport is how many notes there are, and by how many people.
db.NotesSinceone row, or no such rowNotesSince is how many notes were written after a time.
db.RecordActivityone row, or no such rowINSERT INTO activity (kind, note_id, author, notes) VALUES (?, ?, ?, ?) RETURNING *
db.ForgetNotenothingForgetNote takes away what was recorded of a note: it goes with the note.
db.ActivityBeforerowsActivityBefore is what happened before a position, newest first.
db.ActivityAfterrowsActivityAfter is what happened after a position, oldest first: the log its feed follows.
db.NewestActivityone row, or no such rowSELECT CAST(COALESCE(MAX(id), 0) AS INTEGER) AS id FROM activity
db.AddAttachmentone row, or no such rowINSERT INTO attachments (object, name, type, size, note_id, author_id, author) VALUES (?, ?, ?, ?, ?, ?, ?) RETURNING *
db.AttachmentsrowsAttachments is the files attached, newest first.
db.AttachmentsByrowsAttachmentsBy is the files someone attached.
db.Attachmentone row, or no such rowSELECT * FROM attachments WHERE id = ?
db.RemoveAttachmentone row, or no such rowDELETE FROM attachments WHERE id = ? RETURNING *