@@ -570,15 +570,16 @@ export const selectFacts = function* <Space extends MemorySpace>(
570570 { store } : Session < Space > ,
571571 { the, of, cause, is, since } : FactSelector ,
572572) : Iterable < SelectedFact > {
573- const rows = store . prepare ( EXPORT ) . all ( {
574- the : the === SelectAllString ? null : the ,
575- of : of === SelectAllString ? null : of ,
576- cause : cause === SelectAllString ? null : cause ,
577- is : is === undefined ? null : { } ,
578- since : since ?? null ,
579- } ) as StateRow [ ] ;
580-
581- for ( const row of rows ) {
573+ const stmt = store . prepare ( EXPORT ) ;
574+ for (
575+ const row of stmt . iter ( {
576+ the : the === SelectAllString ? null : the ,
577+ of : of === SelectAllString ? null : of ,
578+ cause : cause === SelectAllString ? null : cause ,
579+ is : is === undefined ? null : { } ,
580+ since : since ?? null ,
581+ } ) as Iterable < StateRow >
582+ ) {
582583 yield toFact ( row ) ;
583584 }
584585} ;
@@ -587,14 +588,19 @@ export const selectFact = function <Space extends MemorySpace>(
587588 { store } : Session < Space > ,
588589 { the, of, since } : { the : MIME ; of : URI ; since ?: number } ,
589590) : SelectedFact | undefined {
590- const rows = store . prepare ( EXPORT ) . all ( {
591- the : the ,
592- of : of ,
593- cause : null ,
594- is : null ,
595- since : since ?? null ,
596- } ) as StateRow [ ] ;
597- return ( rows . length > 0 ) ? toFact ( rows [ 0 ] ) : undefined ;
591+ const stmt = store . prepare ( EXPORT ) ;
592+ for (
593+ const row of stmt . iter ( {
594+ the : the ,
595+ of : of ,
596+ cause : null ,
597+ is : null ,
598+ since : since ?? null ,
599+ } ) as Iterable < StateRow >
600+ ) {
601+ return toFact ( row ) ;
602+ }
603+ return undefined ;
598604} ;
599605
600606/**
0 commit comments