13 releases (stable)

1.3.1 Jan 30, 2024
1.3.0 Oct 31, 2023
1.2.1 Jul 13, 2023
1.2.0 Jun 28, 2023
0.1.2 Nov 26, 2022

#724 in Magic Beans

Download history 145/week @ 2023-12-18 30/week @ 2023-12-25 77/week @ 2024-01-01 87/week @ 2024-01-08 96/week @ 2024-01-15 113/week @ 2024-01-22 234/week @ 2024-01-29 204/week @ 2024-02-05 166/week @ 2024-02-12 211/week @ 2024-02-19 237/week @ 2024-02-26 154/week @ 2024-03-04 264/week @ 2024-03-11 218/week @ 2024-03-18 334/week @ 2024-03-25 482/week @ 2024-04-01

1,320 downloads per month

Apache-2.0

54KB
1K SLoC

Rust 786 SLoC // 0.0% comments Go 458 SLoC // 0.0% comments

Substreams Sink Database Changes

github crates.io docs.rs GitHub Workflow Status

substreams-sink-database-changes contains all the definitions for database changes which can be emitted by a substream.

Used by

Install

# The Rust crate is named substreams-database-change for historical reasons
cargo add substreams-database-change

Quickstart

Cargo.toml

[dependencies]
substreams = "0.5"
substreams-database-change = "1.0"

src/lib.rs

use substreams::errors::Error;
use substreams_database_change::pb::database::{DatabaseChanges, table_change::Operation};

#[substreams::handlers::map]
fn db_out(
    ... some stores ...
) -> Result<DatabaseChanges, Error> {
    // Initialize Database Changes container
    let mut database_changes: DatabaseChanges = Default::default();

    // Push change
    database_changes.push_change("transfer", "primary-key", 0, Operation::Create)
        .change("key1", ("previous1", "value1"))
        .change("key2", ("previous2", "value2"));

    Ok(database_changes)
}

Re-generate Protobuf

Be sure to have buf CLI installed (https://buf.build/docs/installation/) and run:

buf generate proto

Dependencies

~3–5MB
~94K SLoC