Skip to content

Commit

Permalink
Merge pull request #15 from x100111010/wallet
Browse files Browse the repository at this point in the history
Update `Inner::open_db` to use `set_unique()`
  • Loading branch information
0xA001113 authored Oct 16, 2024
2 parents b46c66d + 539af9c commit 2ed9210
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions wallet/core/src/storage/local/transaction/indexdb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,20 +33,29 @@ impl Inner {
// Check if the object store exists; create it if it doesn't
if !evt.db().object_store_names().any(|n| n == TRANSACTIONS_STORE_NAME) {
let object_store = evt.db().create_object_store(TRANSACTIONS_STORE_NAME)?;

let id_index_params = IdbIndexParameters::new();
id_index_params.set_unique(true);
object_store.create_index_with_params(
TRANSACTIONS_STORE_ID_INDEX,
&IdbKeyPath::str(TRANSACTIONS_STORE_ID_INDEX),
IdbIndexParameters::new().unique(true),
&id_index_params,
)?;

let timestamp_index_params = IdbIndexParameters::new();
timestamp_index_params.set_unique(false);
object_store.create_index_with_params(
TRANSACTIONS_STORE_TIMESTAMP_INDEX,
&IdbKeyPath::str(TRANSACTIONS_STORE_TIMESTAMP_INDEX),
IdbIndexParameters::new().unique(false),
&timestamp_index_params,
)?;

let data_index_params = IdbIndexParameters::new();
data_index_params.set_unique(false);
object_store.create_index_with_params(
TRANSACTIONS_STORE_DATA_INDEX,
&IdbKeyPath::str(TRANSACTIONS_STORE_DATA_INDEX),
IdbIndexParameters::new().unique(false),
&data_index_params,
)?;
}
Ok(())
Expand Down

0 comments on commit 2ed9210

Please sign in to comment.