Skip to content

Releases: tinyplex/tinybase

v6.5.0

Choose a tag to compare

@jamesgpearce jamesgpearce released this 26 Jul 20:12

This release includes the new persister-react-native-mmkv module, which allows you to persist data in a React Native MMKV store via the react-native-mmkv library.

Usage should be as simple as this:

import {MMKV} from 'react-native-mmkv';
import {createStore} from 'tinybase';
import {createReactNativeMmkvPersister} from 'tinybase/persisters/persister-react-native-mmkv';

const storage = new MMKV();
const store = createStore().setTables({pets: {fido: {species: 'dog'}}});
const persister = createReactNativeMmkvPersister(store, storage);

await persister.save();
// Store will be saved to the MMKV store.

A huge shout out to Jérémy Barbet for this new persister!

v6.4.2

Choose a tag to compare

@jamesgpearce jamesgpearce released this 24 Jul 23:04

This release merges #263.

v6.4.1

Choose a tag to compare

@jamesgpearce jamesgpearce released this 24 Jul 22:19

This release updates dependencies.

v6.4.0

Choose a tag to compare

@jamesgpearce jamesgpearce released this 10 Jul 21:40

This release includes the new persister-react-native-sqlite module, which allows you to persist data in a React Native SQLite database via the react-native-sqlite-storage library.

Usage should be as simple as this:

import {enablePromise, openDatabase} from 'react-native-sqlite-storage';
import {createStore} from 'tinybase';
import {createReactNativeSqlitePersister} from 'tinybase/persisters/persister-react-native-sqlite';

enablePromise(true);
const db = await openDatabase({name: 'my.db', location: 'default'});
const store = createStore().setTables({pets: {fido: {species: 'dog'}}});
const persister = createReactNativeSqlitePersister(store, db);

await persister.save();
// Store will be saved to the database.

Please let us know how you get on with this new Persister, and if you have any feedback or suggestions.

v6.3.1

Choose a tag to compare

@jamesgpearce jamesgpearce released this 09 Jul 12:29

This release updates dependencies.

v6.3.0

Choose a tag to compare

@jamesgpearce jamesgpearce released this 20 Jun 22:40

This release includes the new persister-durable-object-sql-storage module, which allows you to persist data in a Cloudflare Durable Object's SQLite-based storage in conjunction with websocket-based synchronization (using the WsServerDurableObject class).

Huge thanks to Corey Jepperson, @acoreyj, for implementing the entirety of this functionality!

import {createMergeableStore} from 'tinybase';
import {createDurableObjectSqlStoragePersister} from 'tinybase/persisters/persister-durable-object-sql-storage';
import {WsServerDurableObject} from 'tinybase/synchronizers/synchronizer-ws-server-durable-object';

const config = {
  mode: 'fragmented',
  storagePrefix: 'my_app_',
};

export class MyDurableObject extends WsServerDurableObject {
  createPersister() {
    const store = createMergeableStore();
    const persister = createDurableObjectSqlStoragePersister(
      store,
      this.ctx.storage.sql,
      config,
    );
    return persister;
  }
}

Prior to this release, the only way to persist data in a Durable Object was to use the persister-durable-object-storage module, which uses CloudFlare's key-value storage backend behind the scenes.

However, Cloudflare's SQLite storage backend for Durable Objects offers significantly better pricing compared to the key-value storage backend. The SQLite storage backend is Cloudflare's recommended storage option for new Durable Object namespaces.

Note that, before using this persister, you must configure your Durable Object class to use SQLite storage by adding a migration to your wrangler.toml or wrangler.json configuration file. Use new_sqlite_classes in your migration configuration to enable SQLite storage for your Durable Object class. See the module documentation for more information.

This release also addresses a local-storage persistence issue, #257.

v6.2.1

Choose a tag to compare

@jamesgpearce jamesgpearce released this 05 Jun 23:16

This release updates dependencies.

v6.2.0

Choose a tag to compare

@jamesgpearce jamesgpearce released this 31 May 21:08

This release contains various packaging improvements and exposes some internal HLC functions that are useful for people building their own persisters or synchronizers.

New omni module

There is a new omni module that is an explicit superset of everything in the TinyBase ecosystem. It exports the features and functionality of every tinybase/* module, including every persister, every synchronizer, and every UI component. This is useful for applications that want to use multiple facets of the overall TinyBase ecosystem and also benefit from the fact they share a lot of code internally.

import {createStore, createSqliteBunPersister} from 'tinybase/omni';

However, it should go without saying that you should only use the omni module if you have an aggressive tree-shaking bundler that can remove all the persisters, synchronizers, and so on, that you do not use. Experiment with different bundler configurations to see what works best for your usage.

with-schema exports

This release changes the package.json exports slightly so that imports of both /with-schema and non-schema'd versions of the modules resolve to the same JavaScript file. This reduces bundle size for apps that use both schema and non-schema imports.

HLC & hash functions

The common module (and hence tinybase module) now export the getHlcFunctions function. This returns set of seven functions that can be used to create and manipulate HLC (Hybrid Logical Clock) timestamps.

import {getHlcFunctions} from 'tinybase';
const [getNextHlc, seenHlc, encodeHlc] = getHlcFunctions();

There are also several functions to help hash tabular and key-value data in a way that is compatible with the internal MergeableStore implementation. These include the getHash function and the getCellHash function, for example.

These are for pretty advanced use-cases! But you can use these in your own systems to ensure the timestamps and hashes are compatible with the ones generated in TinyBase MergeableStore objects.

Moved types

The rarely-used GetNow and Hash types have been moved from the mergeable-store module into the common module.

v6.1.2

Choose a tag to compare

@jamesgpearce jamesgpearce released this 25 May 01:40

This release updates dependencies and fixes minor documentation issues.

v6.2.0-beta.1

v6.2.0-beta.1 Pre-release
Pre-release

Choose a tag to compare

@jamesgpearce jamesgpearce released this 18 May 18:47

with-schema exports

This release changes the package.json exports slightly so that imports of both /with-schema and non-schema'd versions of the modules resolve to the same JavaScript file. This reduces bundle size for apps that use both schema and non-schema imports.