The foundation for large Triplit databases
TLDR
We make low-level database changes to improve performance and reduce memory use, write a guide to integrate Clerk auth, and add an `isDefined` filter.
Important improvements for large databases
We've made some fundamental changes to how database operations are executed at a low level. In general, Triplit loads data from it's underlying storage into memory more lazily, which should result in a smaller memory footprint and faster performance for all caches and servers, but the improvements will be especially noticeable for large datasets. We're excited to see how this will improve performance for our developers working in production.
New isDefined
filters
We've added a new filter method, isDefined
, which allows you to check if an attribute is defined. This is useful for those collection with optional attributes, when you want to filter out entities that do or don't have a certain attribute.
For a profile schema with an optional email
attribute, you can get all profiles with an email defined like this:
const queryProfilesWithEmails = client
.query('profiles')
.where('email', 'isDefined', true)
.build();
Getting started with Clerk auth
We've had a few developers in the Triplit community use Clerk for authentication, so we've added a guide to help you get started with Clerk and Triplit. We've found Clerk to be a great solution for developers who want to get started with authentication quickly.
Once you've setup a Clerk application and added its public key to your Triplit server, you can use it with your Triplit client in just a few lines of code:
// get the Clerk client or session using your framework
// e.g. `const auth = useAuth()` from @clerk/clerk-react
auth.getToken().then((token) => {
token && client.updateToken(token);
});
You can find the guide here.
Simplified token requirements for external authentication services
One of the pieces of feedback we've received from developers is that the token requirements of Triplit-specific claims were complicated to implement with some external authentication services. Triplit is now completely agnostic as to the claims on external tokens, so long as the Triplit server is provided a secret / validation key to authenticate external tokens. This pairs nicely with the release of our Permissions API, which allows you to define roles based on any arbitrary claims on the token. This should make it easier to integrate Triplit with any external authentication service.
Read more about integrating external authentication with Triplit here.