Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

replicache-transaction

Package Overview
Dependencies
Maintainers
0
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

replicache-transaction

Adapter from Replicache's WriteTransaction interface to some key/value storage.

  • 0.4.0
  • canary
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
0
Created
Source

replicache-transaction

This is an adapter from Replicache's WriteTransaction to some key/value storage.

It's useful when you want to reuse Replicache mutator functions on the backend. All you have to do is provide a suitable implementation of the "Storage" interface, for example against your backend SQL database and then execute each of the mutations in a Replicache push request using them.

ReplicacheTransaction also implements an in-memory cache for entries over the lifetime of the transaction so that repeated reads and writes for same key don't go back and forth to the database.

Usage

import mutators from './my-mutators.ts';

class MyStorage implements Storage {
  // ...
}

const myStorage = new MyStorage(dbconn, spaceID, version);
const tx = new ReplicacheTransaction(storage, clientID);

const createTodo = mutators.createTodo;
await createTodo(tx, {title: 'Hello, shared mutators', complete: false});

await tx.flush();

See replicache-express for a complete example.

Important: Sort Order

It is important that the getEntries() method returns keys in order of their UTF-8 byte encoding. This is a collation option in most databases. See https://blog.replicache.dev/blog/replicache-11-adventures-in-text-encoding for more information.

Contributing

PRs and feature requests are welcome!

FAQs

Package last updated on 22 Jul 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc