-- @query search_favorites
-- @db media 11.0
-- @param item_ids TEXT
SELECT cloud.driveItemId AS driveItemId
FROM media.media_properties AS cloud
JOIN media.media_libraries AS drive
    ON cloud.driveId = drive.driveId
WHERE cloud.driveItemId IN (SELECT value FROM json_each(?item_ids))
  AND cloud.isTombstoned = 0
  AND EXISTS (
      SELECT 1 FROM media.media_favorites mf
      WHERE mf.listItemUniqueId = cloud.listItemUniqueId
        AND mf.siteId = drive.siteId
        AND mf.listId = drive.listId
  )
