feat: add notes app
This commit is contained in:
@@ -0,0 +1,4 @@
|
||||
export default defineEventHandler(async (event) => {
|
||||
await deleteRow(event, notesTable(event), notesDocId(event))
|
||||
return { deleted: true }
|
||||
})
|
||||
@@ -0,0 +1,3 @@
|
||||
export default defineEventHandler(async (event) => {
|
||||
return toNotesDoc(await getRow<NotesDocRow>(event, notesTable(event), notesDocId(event)))
|
||||
})
|
||||
@@ -0,0 +1,5 @@
|
||||
export default defineEventHandler(async (event) => {
|
||||
const changes = await readValidBody(event, notesDocUpdateSchema)
|
||||
const row = await updateRow<NotesDocRow>(event, notesTable(event), notesDocId(event), { ...changes, updated: notesNow() })
|
||||
return toNotesDocSummary(row)
|
||||
})
|
||||
@@ -0,0 +1,11 @@
|
||||
// ?q= searches title and text with Baserow's search. Baserow only searches (and filters) the fields a request
|
||||
// includes, so a search has to include `content` even though the list only needs the summary.
|
||||
export default defineEventHandler(async (event) => {
|
||||
const q = String(getQuery(event).q ?? '').trim()
|
||||
const query = q
|
||||
? { include: `${NOTES_SUMMARY_FIELDS},content`, search: q }
|
||||
: { include: NOTES_SUMMARY_FIELDS }
|
||||
|
||||
const rows = await listRows<NotesDocRow>(event, notesTable(event), query)
|
||||
return rows.map(toNotesDocSummary)
|
||||
})
|
||||
@@ -0,0 +1,4 @@
|
||||
export default defineEventHandler(async (event) => {
|
||||
const row = await createRow<NotesDocRow>(event, notesTable(event), { title: '', content: '', created: notesNow(), updated: notesNow() })
|
||||
return toNotesDoc(row)
|
||||
})
|
||||
Reference in New Issue
Block a user