1.4 KiB
1.4 KiB
TaylorDB Attachments
Attachments are treated as standard columns and can be selected and written like other fields, using helper utilities for uploads.
This document covers:
- Selecting attachment fields
- Creating records with attachments
- Updating attachments
Select Attachments
// New Standard: Use regular .select() like any other field.
const expenses = await qb
.selectFrom("expenses")
.select(["id", "amount", "receipt"])
.execute();
Create with Attachments
Use qb.uploadAttachments to upload files before inserting.
await qb
.insertInto("customers")
.values({
firstName: "Jane",
lastName: "Doe",
avatar: await qb.uploadAttachments([
{ file: new Blob([""]), name: "test.png" },
]),
})
.execute();
Update with Attachments
await qb
.update("customers")
.set({
lastName: "Smith",
avatar: await qb.uploadAttachments([
{ file: new Blob([""]), name: "test.png" },
]),
})
.where("id", "=", 1)
.execute();
For more topics, see:
TAYLORDB_BASIC_QUERIES.mdfor basic reads and filteringTAYLORDB_WRITE_OPERATIONS.mdfor inserts, updates, and deletesTAYLORDB_ADVANCED_PATTERNS.mdfor aggregations, pagination, and conditional queriesTAYLORDB_FIELD_TYPES.mdfor field type handling and enumsTAYLORDB_PITFALLS_BEST_PRACTICES.mdfor pitfalls and best practices