- Web
- Mobile
- React Native
- Async Storage (can opt in to use SQLite)
- React Native
- SSR
We determine the storage adapter here.
- The Storage class is what interacts with the adapters.
- There is one adapter per database type we support (i.e. three adapters).
- Each adapter provides a unified API for the storage engine to interact with.
- The SQLite adapter lives in it’s own package.
- ExclusiveStorage wraps public storage methods (e.g.
Storage.runExclusive
)- Guarantees consistency
- Makes the storage class transactional
- Provides concurrency control
- Varies by storage adapter
- SQLiteAdapter: DataStore constructs a query.
- Async Storage: DataStore scans and filters.
- IndexedDB: if the query is by primary key, DataStore queries against the index, otherwise it scans and filters.
- Note: The lazy loading branch includes an improvement to the IndexedDB adapter that will check if any search criteria can leverage an index (there is no preference for low cardinality; the first identified index is used.) If so, the base result is sourced from the index and the remaining criteria will be applied as a filter.
- As the names imply,
save
accepts a single record and persists it, whilebatchSave
accepts a page of records and persists them all.batchSave
, however, is only used within the sync processor, and will filter out deleted records from the sync page results, and then delete them from the local db.