Skip to content

Instantly share code, notes, and snippets.

@oukayuka
Created December 10, 2019 11:04
Show Gist options
  • Save oukayuka/9de3460161bf8100fc9c849fedb94547 to your computer and use it in GitHub Desktop.
Save oukayuka/9de3460161bf8100fc9c849fedb94547 to your computer and use it in GitHub Desktop.
Firestore のスナップショットをいい感じにキャッシュしてくれるライブラリの構想
import { getByQuery, strategies } from 'firestore-snapbox';
const maxEntries = 100;
const maxAgeSeconds = 60 * 60;
const expiredDate = new Date(2020, 0, 10, 15);
const snap = await getByQuery(query, strategies.CacheFirst, { maxEntries, maxAgeSeconds, expiredDate });
const books = snap.docs.map(doc => { ...doc, id: doc.id } as Book);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment