WatermelonDB v0.16.0-9 Release Notes

Release Date: 2020-01-20 // about 1 month ago

Previous changes from v0.15

  • 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