Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 0 additions & 9 deletions demos/supabase-todolist/lib/attachments/queue.dart
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,3 @@ Future<Attachment> savePhotoAttachment(
},
);
}

Future<Attachment> deletePhotoAttachment(String fileId) async {
return await attachmentQueue.deleteFile(
attachmentId: fileId,
updateHook: (context, attachment) async {
// Optionally update relationships in the same transaction
},
);
}
5 changes: 5 additions & 0 deletions packages/powersync_core/doc/attachments.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ The attachments' state is stored in a local-only attachments table.

See the [supabase-todolist](https://github.com/powersync-ja/powersync.dart/tree/main/demos/supabase-todolist) demo for a basic example of attachment syncing.

In particular, relevant snippets from that example are:

- The attachment queue is set up [here](https://github.com/powersync-ja/powersync.dart/blob/98d73e2f157a697786373fef755576505abc74a5/demos/supabase-todolist/lib/attachments/queue.dart#L16-L36), using conditional imports to store attachments in the file system on native platforms and in-memory for web.
- When a new attachment is added, `saveFile` is called [here](https://github.com/powersync-ja/powersync.dart/blob/98d73e2f157a697786373fef755576505abc74a5/demos/supabase-todolist/lib/attachments/queue.dart#L38-L55) and automatically updates references in the main schema to reference the attachment.

### Setup

First, add a table storing local attachment state to your database schema.
Expand Down