@@ -113,19 +113,17 @@ describe(`includes subqueries`, () => {
113113
114114 function buildIncludesQuery ( ) {
115115 return createLiveQueryCollection ( ( q ) =>
116- q
117- . from ( { p : projects } )
118- . select ( ( { p } ) => ( {
119- id : p . id ,
120- name : p . name ,
121- issues : q
122- . from ( { i : issues } )
123- . where ( ( { i } ) => eq ( i . projectId , p . id ) )
124- . select ( ( { i } ) => ( {
125- id : i . id ,
126- title : i . title ,
127- } ) ) ,
128- } ) ) ,
116+ q . from ( { p : projects } ) . select ( ( { p } ) => ( {
117+ id : p . id ,
118+ name : p . name ,
119+ issues : q
120+ . from ( { i : issues } )
121+ . where ( ( { i } ) => eq ( i . projectId , p . id ) )
122+ . select ( ( { i } ) => ( {
123+ id : i . id ,
124+ title : i . title ,
125+ } ) ) ,
126+ } ) ) ,
129127 )
130128 }
131129
@@ -155,8 +153,7 @@ describe(`includes subqueries`, () => {
155153 } ,
156154 ] )
157155 } )
158-
159- } )
156+ } )
160157
161158 describe ( `reactivity` , ( ) => {
162159 it ( `adding a child updates the parent's child collection` , async ( ) => {
@@ -299,20 +296,18 @@ describe(`includes subqueries`, () => {
299296 describe ( `ordered child queries` , ( ) => {
300297 it ( `child collection respects orderBy on the child query` , async ( ) => {
301298 const collection = createLiveQueryCollection ( ( q ) =>
302- q
303- . from ( { p : projects } )
304- . select ( ( { p } ) => ( {
305- id : p . id ,
306- name : p . name ,
307- issues : q
308- . from ( { i : issues } )
309- . where ( ( { i } ) => eq ( i . projectId , p . id ) )
310- . orderBy ( ( { i } ) => i . title , `desc` )
311- . select ( ( { i } ) => ( {
312- id : i . id ,
313- title : i . title ,
314- } ) ) ,
315- } ) ) ,
299+ q . from ( { p : projects } ) . select ( ( { p } ) => ( {
300+ id : p . id ,
301+ name : p . name ,
302+ issues : q
303+ . from ( { i : issues } )
304+ . where ( ( { i } ) => eq ( i . projectId , p . id ) )
305+ . orderBy ( ( { i } ) => i . title , `desc` )
306+ . select ( ( { i } ) => ( {
307+ id : i . id ,
308+ title : i . title ,
309+ } ) ) ,
310+ } ) ) ,
316311 )
317312
318313 await collection . preload ( )
@@ -338,20 +333,18 @@ describe(`includes subqueries`, () => {
338333
339334 it ( `newly inserted children appear in the correct order` , async ( ) => {
340335 const collection = createLiveQueryCollection ( ( q ) =>
341- q
342- . from ( { p : projects } )
343- . select ( ( { p } ) => ( {
344- id : p . id ,
345- name : p . name ,
346- issues : q
347- . from ( { i : issues } )
348- . where ( ( { i } ) => eq ( i . projectId , p . id ) )
349- . orderBy ( ( { i } ) => i . title , `asc` )
350- . select ( ( { i } ) => ( {
351- id : i . id ,
352- title : i . title ,
353- } ) ) ,
354- } ) ) ,
336+ q . from ( { p : projects } ) . select ( ( { p } ) => ( {
337+ id : p . id ,
338+ name : p . name ,
339+ issues : q
340+ . from ( { i : issues } )
341+ . where ( ( { i } ) => eq ( i . projectId , p . id ) )
342+ . orderBy ( ( { i } ) => i . title , `asc` )
343+ . select ( ( { i } ) => ( {
344+ id : i . id ,
345+ title : i . title ,
346+ } ) ) ,
347+ } ) ) ,
355348 )
356349
357350 await collection . preload ( )
@@ -382,21 +375,19 @@ describe(`includes subqueries`, () => {
382375 describe ( `ordered child queries with limit` , ( ) => {
383376 it ( `limits child collection to N items per parent` , async ( ) => {
384377 const collection = createLiveQueryCollection ( ( q ) =>
385- q
386- . from ( { p : projects } )
387- . select ( ( { p } ) => ( {
388- id : p . id ,
389- name : p . name ,
390- issues : q
391- . from ( { i : issues } )
392- . where ( ( { i } ) => eq ( i . projectId , p . id ) )
393- . orderBy ( ( { i } ) => i . title , `asc` )
394- . limit ( 1 )
395- . select ( ( { i } ) => ( {
396- id : i . id ,
397- title : i . title ,
398- } ) ) ,
399- } ) ) ,
378+ q . from ( { p : projects } ) . select ( ( { p } ) => ( {
379+ id : p . id ,
380+ name : p . name ,
381+ issues : q
382+ . from ( { i : issues } )
383+ . where ( ( { i } ) => eq ( i . projectId , p . id ) )
384+ . orderBy ( ( { i } ) => i . title , `asc` )
385+ . limit ( 1 )
386+ . select ( ( { i } ) => ( {
387+ id : i . id ,
388+ title : i . title ,
389+ } ) ) ,
390+ } ) ) ,
400391 )
401392
402393 await collection . preload ( )
@@ -420,31 +411,27 @@ describe(`includes subqueries`, () => {
420411
421412 it ( `inserting a child that displaces an existing one respects the limit` , async ( ) => {
422413 const collection = createLiveQueryCollection ( ( q ) =>
423- q
424- . from ( { p : projects } )
425- . select ( ( { p } ) => ( {
426- id : p . id ,
427- name : p . name ,
428- issues : q
429- . from ( { i : issues } )
430- . where ( ( { i } ) => eq ( i . projectId , p . id ) )
431- . orderBy ( ( { i } ) => i . title , `asc` )
432- . limit ( 1 )
433- . select ( ( { i } ) => ( {
434- id : i . id ,
435- title : i . title ,
436- } ) ) ,
437- } ) ) ,
414+ q . from ( { p : projects } ) . select ( ( { p } ) => ( {
415+ id : p . id ,
416+ name : p . name ,
417+ issues : q
418+ . from ( { i : issues } )
419+ . where ( ( { i } ) => eq ( i . projectId , p . id ) )
420+ . orderBy ( ( { i } ) => i . title , `asc` )
421+ . limit ( 1 )
422+ . select ( ( { i } ) => ( {
423+ id : i . id ,
424+ title : i . title ,
425+ } ) ) ,
426+ } ) ) ,
438427 )
439428
440429 await collection . preload ( )
441430
442431 // Alpha should have exactly 1 issue (limit 1): "Bug in Alpha"
443432 const alphaIssues = [ ...( collection . get ( 1 ) as any ) . issues . toArray ]
444433 expect ( alphaIssues ) . toHaveLength ( 1 )
445- expect ( alphaIssues ) . toEqual ( [
446- { id : 10 , title : `Bug in Alpha` } ,
447- ] )
434+ expect ( alphaIssues ) . toEqual ( [ { id : 10 , title : `Bug in Alpha` } ] )
448435
449436 // Insert an issue that comes before "Bug" alphabetically
450437 issues . utils . begin ( )
@@ -469,26 +456,24 @@ describe(`includes subqueries`, () => {
469456 describe ( `nested includes` , ( ) => {
470457 it ( `supports two levels of includes` , async ( ) => {
471458 const collection = createLiveQueryCollection ( ( q ) =>
472- q
473- . from ( { p : projects } )
474- . select ( ( { p } ) => ( {
475- id : p . id ,
476- name : p . name ,
477- issues : q
478- . from ( { i : issues } )
479- . where ( ( { i } ) => eq ( i . projectId , p . id ) )
480- . select ( ( { i } ) => ( {
481- id : i . id ,
482- title : i . title ,
483- comments : q
484- . from ( { c : comments } )
485- . where ( ( { c } ) => eq ( c . issueId , i . id ) )
486- . select ( ( { c } ) => ( {
487- id : c . id ,
488- body : c . body ,
489- } ) ) ,
490- } ) ) ,
491- } ) ) ,
459+ q . from ( { p : projects } ) . select ( ( { p } ) => ( {
460+ id : p . id ,
461+ name : p . name ,
462+ issues : q
463+ . from ( { i : issues } )
464+ . where ( ( { i } ) => eq ( i . projectId , p . id ) )
465+ . select ( ( { i } ) => ( {
466+ id : i . id ,
467+ title : i . title ,
468+ comments : q
469+ . from ( { c : comments } )
470+ . where ( ( { c } ) => eq ( c . issueId , i . id ) )
471+ . select ( ( { c } ) => ( {
472+ id : c . id ,
473+ body : c . body ,
474+ } ) ) ,
475+ } ) ) ,
476+ } ) ) ,
492477 )
493478
494479 await collection . preload ( )
0 commit comments