pub struct Row {
pub operation: Operation,
pub columns: HashMap<String, String>,
pub finalized: bool,
/* private fields */
}
Fields§
§operation: Operation
Verify that we don’t try to delete the same row as we’re creating it
columns: HashMap<String, String>
Map of field name to its last change
finalized: bool
operation
field.Finalized: Last update or delete
Implementations§
Source§impl Row
impl Row
Sourcepub fn new() -> Self
👎Deprecated: Do now create a new row manually, use the Tables
API instead like create_row
, upsert_row
, update_row
, or delete_row
pub fn new() -> Self
Tables
API instead like create_row
, upsert_row
, update_row
, or delete_row
Do not use Now broken, use the Tables
API instead like create_row
, upsert_row
, update_row
, or delete_row
.
Kept for code compilation but it’s expected that this was never used in practice.
Sourcepub fn set<T: ToDatabaseValue>(&mut self, name: &str, value: T) -> &mut Self
pub fn set<T: ToDatabaseValue>(&mut self, name: &str, value: T) -> &mut Self
Set a field to a value, this is the standard method for setting fields in a row.
This method ensures that the value is converted to a database-compatible format
using the ToDatabaseValue
trait. It is the primary way to set fields in a row
for most use cases.
The ToDatabaseValue
trait is implemented for various types, including primitive
types, strings, and custom types. This allows you to set fields with different
types of values without worrying about the underlying conversion. Check example
for more details.
Check ToDatabaseValue for implemented automatic conversions.
§Panics
This method will panic if called on a row marked for deletion.
§Example
use substreams::scalar::{BigInt, BigDecimal};
use crate::substreams_database_change::tables::Tables;
let mut tables = Tables::new();
let row = tables.create_row("myevent", "my_key");
row.set("name", "asset name");
row.set("decimals", 42);
row.set("count", BigDecimal::from(42));
row.set("value", BigInt::from(42));
Sourcepub fn set_raw(&mut self, name: &str, value: String) -> &mut Self
pub fn set_raw(&mut self, name: &str, value: String) -> &mut Self
Set a field to a raw value, this is useful for setting values that are not normalized across all databases. In there, you can put the raw value as you would in a SQL statement of the database you are targeting.
This will be pass as a string to the database which will interpret it itself.