Many enhancements were shipped in July — let’s get into them.
Improvements to Sync Rules Syntax
Sync Rules control what Postgres data gets synced with individual in-app SQLite databases.
It’s useful to think of Sync Rules as a two stage ETL pipeline: the first stage, the parameter query, takes the auth JWT as input and returns a result set. The second stage takes the parameter query results and applies the data query/queries to them.
The previous syntax for Sync Rules’ parameter queries had unintuitive mappings between JWT data and accepted parameters.
Now, the full JWT is passed to Sync Rules as a JSON string, so any JWT field can be referenced:
user_list:
parameters: SELECT id AS list_id FROM lists WHERE email = request.jwt() ->>
'email'
Support for Passing Parameters From PowerSync Clients Directly
We also added support for client parameters - they provide an alternative way to pass parameters to Sync Rules. This opens new possibilities for dynamic syncing, which is useful for:
- Lazy-loading large datasets on the client app.
- Syncing data based on state in the client app. For example: only sync data for the customer currently selected.
- Syncing different data based on the client version.
It’s important to keep in mind that client parameters are not server-authoritative. Read more here.
Support for client parameters is available in the following SDK versions:
- Flutter v1.5.3
- React Native v1.7.2
- JS Web v1.1.0
Bucket History Compacting
V0.5.1 of the PowerSync Service implements a [.inline-code-snippet]compact[.inline-code-snippet] command, which compacts sync bucket history, optimizing sync performance for client applications.
In most cases it will reduce the number of sync operations to clients, thereby reducing load on the sync service. Note:
- PowerSync Cloud instances are automatically compacted once per day
- Self-hosted instances can be compacted using a [.inline-code-snippet]docker run[.inline-code-snippet] command
Flutter Client SDK Web Support
We shipped version 1.6.3 of the PowerSync Dart SDK, which includes many improvements to our Flutter Web support.
- Use of the new [.inline-code-snippet]sqlite3_web[.inline-code-snippet] package from Simon Binder, the maintainer of Dart’s SQLite3 and Drift packages:
- This gives us support for database connections being shared between multiple tabs and it also seems to result in a much more responsive Flutter Web application.
- More robust multiple tab support
- We also implemented Navigator locks which are shared between tabs, making multiple tab support more reliable (in the future we'll implement shared sync coordination between tabs).
- Web support in [.inline-code-snippet]sqlite_async.dart[.inline-code-snippet] (our Dart SQLite library used by our Flutter/Dart SDK)
- This allows using the Drift ORM helper package in Flutter Web.
- Flutter Web support is now available in the main [.inline-code-snippet]powersync[.inline-code-snippet] package (no longer in the separate [.inline-code-snippet]-alpha[.inline-code-snippet] branch)
[Post] React Native Database Performance Comparison
Our fork of [.inline-code-snippet]react-native-quick-sqlite[.inline-code-snippet] contains some changes and enhancements. To test its performance, we ran it through performance benchmark tests. We then ran other popular React Native SQLite libraries through the same tests so that we could compare relative performance.
We tested the following SQLite libraries for React Native:
- [.inline-code-snippet]op-sqlite[.inline-code-snippet]
- [.inline-code-snippet]react-native-quick-sqlite[.inline-code-snippet]
- PowerSync fork of [.inline-code-snippet]react-native-quick-sqlite[.inline-code-snippet]
- [.inline-code-snippet]expo-sqlite[.inline-code-snippet]
[Newsletter] Local-First News Launched
We’re continuously keeping track of the latest developments in the local-first space and imagine many developers are doing the same. Since there’s so much happening, it’s easy to miss things if you’re not constantly on top of it.
We set up Local-First News as a weekly newsletter that covers our own research, but also allows anyone to contribute with their finds or releases.
PowerSync Swag Loading…
Our first swag order is in the works. We’re celebrating the availability of PowerSync V1.0 — which marked PowerSync becoming one of the few sync engines ready for production use. Here’s to our next big milestone!
Want to get in on some free swag? Send us your T-shirt size and a shipping address!
Community Focus
Fig is a tool for freelancers to plan for taxes and save for retirement, with automated bookkeeping and retirement planning, being built with PowerSync. We’re cheering Jason Lewicki on!
Shout-out to the folks at time tracking solution WorkWeek who have recently been hitting some impressive product milestones. Keep winning Trist Drummond and team!
That's it for the July update, happy coding!