Introducing Socket Firewall: Free, Proactive Protection for Your Software Supply Chain.Learn More
Socket
Book a DemoInstallSign in
Socket

@substreams/sink-database-changes

Package Overview
Dependencies
Maintainers
3
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@substreams/sink-database-changes

Substreams Sink Database Changes

latest
npmnpm
Version
0.3.6
Version published
Maintainers
3
Created
Source

Substreams Sink Database Changes

Buf Protobuf codegen & TypeBox for DatabaseChanges.

Quickstart

$ npm install @substreams/sink-database-changes
import { typebox, zod } from "@substreams/sink-database-changes"

Protobuf

message DatabaseChanges {
  repeated TableChange table_changes = 5;
}

message TableChange {
  string table = 1;
  oneof primary_key {
    string pk = 2;
    CompositePrimaryKey composite_pk = 6;
  }
  uint64 ordinal = 3;
  Operation operation = 4;
  repeated Field fields = 5;
}

message Field {
  string name = 1;
  string new_value = 2;
  string old_value = 3;
}

Using TypeBox Static Type Resolution

import { DatabaseChanges } from "@substreams/sink-entity-changes/typebox"
...

const emitter = new BlockEmitter(transport, request, registry);

emitter.on("anyMessage", (message: DatabaseChanges) => {
  for ( const tableChange of message.table_changes ?? []) {
    console.log(tableChange);
  }
});

Using Zod Static Type Resolution

import { DatabaseChanges } from "@substreams/sink-entity-changes/zod"
...

const emitter = new BlockEmitter(transport, request, registry);

emitter.on("anyMessage", (message: DatabaseChanges) => {
  for ( const tableChange of message.table_changes ?? []) {
    console.log(tableChange);
  }
});

Using Buf Protobuf codegen

import { DatabaseChanges } from "@substreams/sink-entity-changes/entity_pb"
...

const emitter = new BlockEmitter(transport, request, registry);

// Stream DatabaseChanges
emitter.on("output", (output: DatabaseChanges) => {
  for ( const tableChange of output?.table_changes ?? []) {
    console.log(tableChange);
  }
});

FAQs

Package last updated on 03 Apr 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