@@ -92,6 +92,14 @@ const coveredQueriesHeaderStyles = css({
9292 marginRight : spacing [ 200 ] ,
9393} ) ;
9494
95+ const coveredQueriesLinkStyles = css ( {
96+ marginTop : spacing [ 200 ] ,
97+ } ) ;
98+
99+ const optimalQueriesStyles = css ( {
100+ marginTop : spacing [ 400 ] ,
101+ } ) ;
102+
95103export type IndexFlowSectionProps = {
96104 fields : Field [ ] ;
97105 createIndexFieldsComponent : JSX . Element | null ;
@@ -148,7 +156,7 @@ const generateOptimalQueries = (
148156
149157 return (
150158 < >
151- { `{"${ firstFieldKey } ":1,"${ lastFieldKey } ":{"$gt":2}}} ` }
159+ { `{"${ firstFieldKey } ":1,"${ lastFieldKey } ":{"$gt":2}}` }
152160 < br />
153161 { `{"${ firstFieldKey } ":1}.sort({"${ lastFieldKey } ":2})` }
154162 </ >
@@ -175,7 +183,7 @@ const generateOptimalQueries = (
175183 // Put last field in range and second to last field in sort
176184 optimalQueries [ lastFieldKey ] = { $gt : coveredQueriesArr . length - 1 } ;
177185 return (
178- JSON . stringify ( optimalQueries ) + `.sort("${ secondToLastFieldKey } ": 1})`
186+ JSON . stringify ( optimalQueries ) + `.sort({ "${ secondToLastFieldKey } ": 1})`
179187 ) ;
180188} ;
181189
@@ -358,51 +366,54 @@ const IndexFlowSection = ({
358366 ) }
359367 >
360368 { /* Covered Queries */ }
361- < Body
362- className = { codeStyles }
363- data-testid = "index-flow-section-covered-queries-examples"
364- >
365- { coveredQueries }
366- </ Body >
367- < p >
368- < Link
369- href = "https://www.mongodb.com/docs/manual/core/query-optimization/"
370- onClick = { ( ) => {
371- track ( 'Covered Queries Learn More Clicked' , {
372- context : 'Create Index Modal' ,
373- } ) ;
374- } }
375- >
376- Learn about covered queries
377- </ Link >
378- </ p >
379369
380- { ! ! optimalQueries && (
381- < >
382- < p >
383- < span className = { underlineStyles } >
384- Follow the Equality, Sort, Range (ESR) Rule. This index is
385- great for queries that have this pattern:
386- </ span >
387- { /* Optimal queries */ }
388- < Body
389- className = { codeStyles }
390- data-testid = "index-flow-section-optimal-queries-examples"
391- >
392- { optimalQueries }
393- </ Body >
394- </ p >
370+ < div >
371+ < Body
372+ className = { codeStyles }
373+ data-testid = "index-flow-section-covered-queries-examples"
374+ >
375+ { coveredQueries }
376+ </ Body >
377+ < div className = { coveredQueriesLinkStyles } >
395378 < Link
396- href = "https://www.mongodb.com/docs/manual/tutorial/equality-sort-range-guideline /"
379+ href = "https://www.mongodb.com/docs/manual/core/query-optimization /"
397380 onClick = { ( ) => {
398- track ( 'ESR Learn More Clicked' , {
381+ track ( 'Covered Queries Learn More Clicked' , {
399382 context : 'Create Index Modal' ,
400383 } ) ;
401384 } }
402385 >
403- Learn about ESR
386+ Learn about covered queries
404387 </ Link >
405- </ >
388+ </ div >
389+ </ div >
390+
391+ { ! ! optimalQueries && (
392+ < div className = { optimalQueriesStyles } >
393+ < span className = { underlineStyles } >
394+ Follow the Equality, Sort, Range (ESR) Rule. This index is
395+ great for queries that have this pattern:
396+ </ span >
397+ { /* Optimal queries */ }
398+ < Body
399+ className = { codeStyles }
400+ data-testid = "index-flow-section-optimal-queries-examples"
401+ >
402+ { optimalQueries }
403+ </ Body >
404+ < div className = { coveredQueriesLinkStyles } >
405+ < Link
406+ href = "https://www.mongodb.com/docs/manual/tutorial/equality-sort-range-guideline/"
407+ onClick = { ( ) => {
408+ track ( 'ESR Learn More Clicked' , {
409+ context : 'Create Index Modal' ,
410+ } ) ;
411+ } }
412+ >
413+ Learn about ESR
414+ </ Link >
415+ </ div >
416+ </ div >
406417 ) }
407418 </ div >
408419 </ >
0 commit comments