WatermelonDB v0.16 Release Notes

Release Date: 2020-03-06 // about 4 years ago
  • โš ๏ธ Breaking

    • experimentalUseIncrementalIndexedDB has been renamed to useIncrementalIndexedDB

    Low breakage risk

    • [adapters] Adapter API has changed from returning Promise to taking callbacks as the last argument. This won't affect you unless you call on adapter methods directly. database.adapter returns a new DatabaseAdapterCompat which has the same shape as old adapter API. You can use database.adapter.underlyingAdapter to get back SQLiteAdapter / LokiJSAdapter
    • ๐Ÿšš [Collection] Collection.fetchQuery and Collection.fetchCount are removed. Please use Query.fetch() and Query.fetchCount().

    ๐Ÿ†• New features

    • ๐Ÿ”€ [SQLiteAdapter] [iOS] Add new synchronous option to adapter: new SQLiteAdapter({ ..., synchronous: true }). When enabled, database operations will block JavaScript thread. Adapter actions will resolve in the next microtask, which simplifies building flicker-free interfaces. Adapter will fall back to async operation when synchronous adapter is not available (e.g. when doing remote debugging)
    • [LokiJS] Added new onQuotaExceededError?: (error: Error) => void option to LokiJSAdapter constructor. This is called when underlying IndexedDB encountered a quota exceeded error (ran out of allotted disk space for app) This means that app can't save more data or that it will fall back to using in-memory database only Note that this only works when useWebWorker: false

    ๐Ÿ”„ Changes

    • ๐ŸŽ [Performance] Watermelon internals have been rewritten not to rely on Promises and allow some fetch/observe calls to resolve synchronously. Do not rely on this -- external API is still based on Rx and Promises and may resolve either asynchronously or synchronously depending on capabilities. This is meant as a internal performance optimization only for the time being.
    • ๐ŸŽ [LokiJS] [Performance] Improved worker queue implementation for performance
    • ๐ŸŽ [observation] Refactored observer implementations for performance

    ๐Ÿ›  Fixes

    • ๐Ÿ›  Fixed a possible cause for "Record ID xxx#yyy was sent over the bridge, but it's not cached" error
    • ๐Ÿ›  [LokiJS] Fixed an issue preventing database from saving when using experimentalUseIncrementalIndexedDB
    • ๐Ÿ›  Fixed a potential issue when using database.unsafeResetDatabase()
    • ๐Ÿ”€ [iOS] Fixed issue with clearing database under experimental synchronous mode

    ๐Ÿ†• New features (Experimental)

    • [Model] Added experimental model.experimentalSubscribe((isDeleted) => { ... }) method as a vanilla JS alternative to Rx based model.observe(). Unlike the latter, it does not notify the subscriber immediately upon subscription.
    • [Collection] Added internal collection.experimentalSubscribe((changeSet) => { ... }) method as a vanilla JS alternative to Rx based collection.changes (you probably shouldn't be using this API anyway)
    • ๐Ÿšฆ [Database] Added experimental database.experimentalSubscribe(['table1', 'table2'], () => { ... }) method as a vanilla JS alternative to Rx-based database.withChangesForTables(). Unlike the latter, experimentalSubscribe notifies the subscriber only once after a batch that makes a change in multiple collections subscribed to. It also doesn't notify the subscriber immediately upon subscription, and doesn't send details about the changes, only a signal.
    • โž• Added experimentalDisableObserveCountThrottling() to @nozbe/watermelondb/observation/observeCount that globally disables count observation throttling. We think that throttling on WatermelonDB level is not a good feature and will be removed in a future release - and will be better implemented on app level if necessary
    • [Query] Added experimental query.experimentalSubscribe(records => { ... }), query.experimentalSubscribeWithColumns(['col1', 'col2'], records => { ... }), and query.experimentalSubscribeToCount(count => { ... }) methods