@@ -109,6 +109,8 @@ pub mod v1 {
109
109
110
110
pub mod keys {
111
111
pub const CORE : & str = "core" ;
112
+ pub const LEASES : & str = "leases" ;
113
+ pub const LEASES_KEY_PATH : & str = "id" ;
112
114
pub const ROOMS : & str = "rooms" ;
113
115
pub const LINKED_CHUNKS : & str = "linked_chunks" ;
114
116
pub const LINKED_CHUNKS_KEY_PATH : & str = "id" ;
@@ -129,19 +131,27 @@ pub mod v1 {
129
131
/// Create all object stores and indices for v1 database
130
132
pub fn create_object_stores ( db : & IdbDatabase ) -> Result < ( ) , DomException > {
131
133
create_core_object_store ( db) ?;
134
+ create_lease_object_store ( db) ?;
132
135
create_linked_chunks_object_store ( db) ?;
133
136
create_events_object_store ( db) ?;
134
137
create_gaps_object_store ( db) ?;
135
138
Ok ( ( ) )
136
139
}
137
140
138
- /// Create an object store for tracking miscellaneous information, e.g.,
139
- /// leases locks
141
+ /// Create an object store for tracking miscellaneous information
140
142
fn create_core_object_store ( db : & IdbDatabase ) -> Result < ( ) , DomException > {
141
143
let _ = db. create_object_store ( keys:: CORE ) ?;
142
144
Ok ( ( ) )
143
145
}
144
146
147
+ /// Create an object store tracking leases on time-based locks
148
+ fn create_lease_object_store ( db : & IdbDatabase ) -> Result < ( ) , DomException > {
149
+ let mut object_store_params = IdbObjectStoreParameters :: new ( ) ;
150
+ object_store_params. key_path ( Some ( & keys:: LEASES_KEY_PATH . into ( ) ) ) ;
151
+ let _ = db. create_object_store_with_params ( keys:: LEASES , & object_store_params) ?;
152
+ Ok ( ( ) )
153
+ }
154
+
145
155
/// Create an object store for tracking information about linked chunks.
146
156
///
147
157
/// * Primary Key - `id`
0 commit comments