-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature/table row support composite keys #6
Feature/table row support composite keys #6
Conversation
CHANGELOG.md
Outdated
* New enum in this crate: `tables::PrimaryKey` | ||
* Single(string): `let sng_pk: PrimaryKey = "hello world".into()` | ||
* Composite(BTreeMap<String, String>: `let cmp_pk: PrimaryKey = [("evt_tx_hash","hello".to_string()),("evt_index","world".to_string())].into()` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* New enum in this crate: `tables::PrimaryKey` | |
* Single(string): `let sng_pk: PrimaryKey = "hello world".into()` | |
* Composite(BTreeMap<String, String>: `let cmp_pk: PrimaryKey = [("evt_tx_hash","hello".to_string()),("evt_index","world".to_string())].into()` | |
* New enum in this crate: `tables::PrimaryKey` | |
* `Single(String)`: `let single: PrimaryKey = "hello world".into()` | |
* `Composite(BTreeMap<String, String>)`: `let composite: PrimaryKey = [("evt_tx_hash","hello".to_string()),("evt_index","world".to_string())].into()` |
src/tables.rs
Outdated
.pks | ||
.entry(key.as_ref().to_string()) | ||
.or_insert(Row::new()); | ||
let key_debug = format!("{:?}", key); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be on the panic
directly. In the sense, inline this code at line 35 directly.
} | ||
} | ||
|
||
impl From<String> for PrimaryKey { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You got a problem with AsRef<str>
?
example usage for composite primary key in BAYC substreams:
note that we don't need the evt_tx_hash and evt_index fields to be repeated in the
set(...)
commands, as they are part of the primary key.The primary could also simply be
format("{}-{}", evt.evt_tx_hash, evt.evt_index).into()
for a Single key.