@@ -406,6 +406,18 @@ impl<'a> IndexeddbEventCacheStoreTransaction<'a> {
406
406
self . get_item_by_key_components :: < Chunk , IndexedChunkIdKey > ( room_id, chunk_id) . await
407
407
}
408
408
409
+ /// Query IndexedDB for chunks such that the next chunk matches the given
410
+ /// chunk identifier in the given room. If more than one item is found,
411
+ /// an error is returned.
412
+ pub async fn get_chunk_by_next_chunk_id (
413
+ & self ,
414
+ room_id : & RoomId ,
415
+ next_chunk_id : & Option < ChunkIdentifier > ,
416
+ ) -> Result < Option < Chunk > , IndexeddbEventCacheStoreTransactionError > {
417
+ self . get_item_by_key_components :: < Chunk , IndexedNextChunkIdKey > ( room_id, next_chunk_id)
418
+ . await
419
+ }
420
+
409
421
/// Query IndexedDB for all chunks in the given room
410
422
pub async fn get_chunks_in_room (
411
423
& self ,
@@ -414,6 +426,22 @@ impl<'a> IndexeddbEventCacheStoreTransaction<'a> {
414
426
self . get_items_in_room :: < Chunk , IndexedChunkIdKey > ( room_id) . await
415
427
}
416
428
429
+ /// Query IndexedDB for the number of chunks in the given room.
430
+ pub async fn get_chunks_count_in_room (
431
+ & self ,
432
+ room_id : & RoomId ,
433
+ ) -> Result < usize , IndexeddbEventCacheStoreTransactionError > {
434
+ self . get_items_count_in_room :: < Chunk , IndexedChunkIdKey > ( room_id) . await
435
+ }
436
+
437
+ /// Query IndexedDB for the chunk with the maximum key in the given room.
438
+ pub async fn get_max_chunk_by_id (
439
+ & self ,
440
+ room_id : & RoomId ,
441
+ ) -> Result < Option < Chunk > , IndexeddbEventCacheStoreTransactionError > {
442
+ self . get_max_item_by_key :: < Chunk , IndexedChunkIdKey > ( room_id) . await
443
+ }
444
+
417
445
/// Query IndexedDB for given chunk in given room and additionally query
418
446
/// for events or gap, depending on chunk type, in order to construct the
419
447
/// full chunk.
0 commit comments