Skip to content

Instantly share code, notes, and snippets.

View wernst's full-sized avatar

Will Ernst wernst

  • Triplit
  • San Francisco, CA
View GitHub Profile
@wernst
wernst / client.ts
Created May 20, 2024 21:59
Triplit client sqlite
import { open } from '@op-engineering/op-sqlite';
import { GenericSQLiteStorage, SQLiteAdapter } from './storage/sqlite';
import { OPSQLiteAdapter } from './storage/op-sqlite-adapter';
const cacheDb = open({ name: 'cacheDB' });
const outboxDb = open({ name: 'outboxDB' });
const cacheStorage = new GenericSQLiteStorage(new OPSQLiteAdapter(cacheDb));
// Uncomment line below to "reset" the data in the cache
// cacheDb.execute('DELETE FROM data;');
const outboxStorage = new GenericSQLiteStorage(new OPSQLiteAdapter(outboxDb));
@wernst
wernst / op-sqlite-storage.ts
Last active May 31, 2024 23:59
Triplit op-sqlite storage
import { OPSQLiteConnection, open } from '@op-engineering/op-sqlite';
import {
AsyncSQLiteAdapter,
AsyncSQLiteExecutor,
AsyncAdapterSQLiteStorage
} from '@triplit/db/storage/adapter-sqlite';
import { AsyncTupleStorageApi } from '@triplit/tuple-database';
// Create DB instance
const db = open({ name: 'triplit.db' });