Refresh views on demand or in batch with client.views.sync
Use views.sync() when you need fresh results right now. A sync re-executes the view query and updates the materialized files in the virtual filesystem.
views.sync() is idempotent and safe to call repeatedly. It is a good fit for pre-read checks, cron jobs, and retryable worker tasks.
This pattern works for periodic refresh workers. Keep sync tasks retry-friendly and continue if one view fails.
Copy
Ask AI
import Airstore from '@airstore/sdk'const airstore = new Airstore()async function syncAllViewsWithRetries(workspaceId: string, attempts = 3) { const views = await airstore.views.list(workspaceId) for (const view of views) { let success = false for (let i = 1; i <= attempts; i += 1) { try { await airstore.views.sync(workspaceId, view.external_id) success = true break } catch (error) { if (i === attempts) { console.error(`Failed syncing ${view.name} after ${attempts} attempts`, error) continue } const backoffMs = i * 1000 await new Promise((resolve) => setTimeout(resolve, backoffMs)) } } if (success) { console.log(`Synced ${view.name}`) } }}// Example: invoke this from your scheduler every 15 minutes.await syncAllViewsWithRetries('ws_abc123')