File tree Expand file tree Collapse file tree 2 files changed +30
-0
lines changed Expand file tree Collapse file tree 2 files changed +30
-0
lines changed Original file line number Diff line number Diff line change @@ -95,6 +95,21 @@ async fn example() -> anyhow::Result<()> {
9595 })
9696 . await ? ;
9797
98+ // More complex example: using cursors to iterate over a store
99+ db . transaction (& [" store" ])
100+ . run (| t | async move {
101+ let mut all_items = Vec :: new ();
102+ let mut cursor = t . object_store (" store" )? . cursor (). open (). await ? ;
103+ while let Some (value ) = cursor . value () {
104+ all_items . push (value );
105+ cursor . advance (1 ). await ? ;
106+ }
107+ assert_eq! (all_items . len (), 3 );
108+ assert_eq! (all_items [0 ], * * JsString :: from (" foo" ));
109+ Ok (())
110+ })
111+ . await ? ;
112+
98113 Ok (())
99114}
100115```
Original file line number Diff line number Diff line change @@ -74,6 +74,21 @@ async fn example() -> anyhow::Result<()> {
7474 } )
7575 . await ?;
7676
77+ // More complex example: using cursors to iterate over a store
78+ db. transaction ( & [ "store" ] )
79+ . run ( |t| async move {
80+ let mut all_items = Vec :: new ( ) ;
81+ let mut cursor = t. object_store ( "store" ) ?. cursor ( ) . open ( ) . await ?;
82+ while let Some ( value) = cursor. value ( ) {
83+ all_items. push ( value) ;
84+ cursor. advance ( 1 ) . await ?;
85+ }
86+ assert_eq ! ( all_items. len( ) , 3 ) ;
87+ assert_eq ! ( all_items[ 0 ] , * * JsString :: from( "foo" ) ) ;
88+ Ok ( ( ) )
89+ } )
90+ . await ?;
91+
7792 Ok ( ( ) )
7893}
7994
You can’t perform that action at this time.
0 commit comments