WatermelonDB v0.15 Release Notes

Release Date: 2019-11-08 // over 4 years ago
  • Highlights

    This is a massive new update to WatermelonDB! ๐Ÿ‰

    • ๐Ÿ”€ Up to 23x faster sync. You heard that right. We've made big improvements to performance. In our tests, with a massive sync (first login, 45MB of data / 65K records) we got a speed up of:
      • 5.7s -> 1.2s on web (5x)
      • 142s -> 6s on iOS (23x)

    Expect more improvements in the coming releases!

    • ๐Ÿ‘Œ Improved LokiJS adapter. Option to disable web workers, important Safari 13 fix, better performance, and now works in Private Modes. We recommend adding useWebWorker: false, experimentalUseIncrementalIndexedDB: true options to the LokiJSAdapter constructor to take advantage of the improvements, but please read further changelog to understand the implications of this.
    • Raw SQL queries now available on iOS and Android thanks to the community
    • ๐Ÿ‘Œ Improved TypeScript support โ€” thanks to the community

    โš ๏ธ Breaking

    • ๐Ÿšš Deprecated bool schema column type is removed -- please change to boolean
    • ๐Ÿšš Experimental experimentalSetOnlyMarkAsChangedIfDiffers(false) API is now removed

    ๐Ÿ†• New featuers

    • [Collection] Add Collection.unsafeFetchRecordsWithSQL() method. You can use it to fetch record using raw SQL queries on iOS and Android. Please be careful to avoid SQL injection and other pitfalls of raw queries
    • [LokiJS] Introduces new new LokiJSAdapter({ ..., experimentalUseIncrementalIndexedDB: true }) option. When enabled, database will be saved to browser's IndexedDB using a new adapter that only saves the changed records, instead of the entire database.

    This works around a serious bug in Safari 13 (https://bugs.webkit.org/show_bug.cgi?id=202137) that causes large databases to quickly balloon to gigabytes of temporary trash

    This also improves performance of incremental saves, although initial page load or very, very large saves might be slightly slower.

    This is intended to become the new default option, but it's not backwards compatible (if enabled, old database will be lost). You're welcome to contribute an automatic migration code.

    Note that this option is still experimental, and might change in breaking ways at any time.

    • ๐Ÿ‘ท [LokiJS] Introduces new new LokiJSAdapter({ ..., useWebWorker: false }) option. Before, web workers were always used with LokiJSAdapter. Although web workers may have some performance benefits, disabling them may lead to lower memory consumption, lower latency, and easier debugging. YMMV.
    • [LokiJS] Added onIndexedDBVersionChange option to LokiJSAdapter. This is a callback that's called when internal IDB version changed (most likely the database was deleted in another browser tab). Pass a callback to force log out in this copy of the app as well. Note that this only works when using incrementalIDB and not using web workers
    • [Model] Add Model._dangerouslySetRawWithoutMarkingColumnChange() method. You probably shouldn't use it, but if you know what you're doing and want to live-update records from server without marking record as updated, this is useful
    • [Collection] Add Collection.prepareCreateFromDirtyRaw()
    • @json decorator sanitizer functions take an optional second argument, with a reference to the model

    ๐Ÿ›  Fixes

    • ๐Ÿš€ Pinned required rambdax version to 2.15.0 to avoid console logging bug. In a future release we will switch to our own fork of rambdax to avoid future breakages like this.

    ๐Ÿ‘Œ Improvements

    • ๐ŸŽ [Performance] Make large batches a lot faster (1.3s shaved off on a 65K insert sample)
    • ๐ŸŽ [Performance] [iOS] Make large batch inserts an order of magnitude faster
    • ๐ŸŽ [Performance] [iOS] Make encoding very large queries (with thousands of parameters) 20x faster
    • ๐ŸŽ [Performance] [LokiJS] Make batch inserts faster (1.5s shaved off on a 65K insert sample)
    • ๐ŸŽ [Performance] [LokiJS] Various performance improvements
    • ๐ŸŽ [Performance] [Sync] Make Sync faster
    • ๐ŸŽ [Performance] Make observation faster
    • ๐ŸŽ [Performance] [Android] Make batches faster
    • ๐Ÿ›  Fix app glitches and performance issues caused by race conditions in Query.observeWithColumns()
    • 0๏ธโƒฃ [LokiJS] Persistence adapter will now be automatically selected based on availability. By default, IndexedDB is used. But now, if unavailable (e.g. in private mode), ephemeral memory adapter will be used.
    • ๐Ÿ”Š Disabled console logs regarding new observations (it never actually counted all observations) and time to query/count/batch (the measures were wildly inaccurate because of asynchronicity - actual times are much lower)
    • ๐ŸŽ [withObservables] Improved performance and debuggability (update withObservables package separately)
    • ๐Ÿ‘Œ Improved debuggability of Watermelon -- shortened Rx stacks and added function names to aid in understanding call stacks and profiles
    • [adapters] The adapters interface has changed. query() and count() methods now receive a SerializedQuery, and batch() now takes TableName<any> and RawRecord or RecordId instead of Model.
    • [Typescript] Typing improvements
      • Added 3 missing properties collections, database and asModel in Model type definition.
      • Removed optional flag on actionsEnabled in the Database constructor options since its mandatory since 0.13.0.
      • fixed several further typing issues in Model, Relation and lazy decorator
    • ๐Ÿ”„ Changed how async functions are transpiled in the library. This could break on really old Android phones but shouldn't matter if you use latest version of React Native. Please report an issue if you see a problem.
    • ๐ŸŒ Avoid database prop drilling in the web demo