feat(server): GET /api/library/sync endpoint
Returns batched upserts + deletes since the supplied cursor. Empty cursor
returns full snapshot; subsequent calls pull deltas. Per-user entities
(likes, playlists) are scoped to the authed user. Composite-key entities
(likes, playlist_tracks) use stable string ids encoded by sync.EncodeLikeID
/ sync.EncodePlaylistTrackID.
Behavior:
204 No Content - no changes since cursor
200 OK - JSON syncResponse {cursor, upserts, deletes}
410 Gone - cursor older than oldest log row; client must reset
401 / 500 - standard envelope errors
Adds sqlc queries GetAlbumsByIDs, GetTracksByIDs, GetPlaylistsByIDs to
mirror the existing GetArtistsByIDs.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -108,3 +108,8 @@ LEFT JOIN albums ON albums.id = t.album_id
|
||||
WHERE pt.playlist_id = $1
|
||||
ORDER BY pt.position
|
||||
LIMIT $2;
|
||||
|
||||
-- name: GetPlaylistsByIDs :many
|
||||
-- Batched lookup used by /api/library/sync to hydrate upsert payloads
|
||||
-- (#357). Mirror of GetArtistsByIDs.
|
||||
SELECT * FROM playlists WHERE id = ANY($1::uuid[]);
|
||||
|
||||
Reference in New Issue
Block a user