@@ -6,7 +6,7 @@ const tg = await typegres({ type: "pglite" });
66const pets = values (
77 { species : Text . new ( "cat" ) , age : Float8 . new ( 2 ) , id : Int8 . new ( 1n ) } ,
88 { species : Text . new ( "dog" ) , age : Float8 . new ( 3 ) , id : Int8 . new ( 2n ) } ,
9- { species : Text . new ( "dog" ) , age : Float8 . new ( 10 ) , id : Int8 . new ( 3n ) } ,
9+ { species : Text . new ( "dog" ) , age : Float8 . new ( 10 ) , id : Int8 . new ( 3n ) }
1010) ;
1111
1212const example1 = await pets
@@ -41,7 +41,7 @@ console.log("Example 2", example2);
4141const people = values (
4242 { id : Int8 . new ( 1n ) , name : Text . new ( "Alice" ) , petId : Int8 . new ( 1n ) } ,
4343 { id : Int8 . new ( 2n ) , name : Text . new ( "Bob" ) , petId : Int8 . new ( 2n ) } ,
44- { id : Int8 . new ( 3n ) , name : Text . new ( "Charlie" ) , petId : Int8 . new ( 3n ) } ,
44+ { id : Int8 . new ( 3n ) , name : Text . new ( "Charlie" ) , petId : Int8 . new ( 3n ) }
4545) ;
4646
4747const example3 = await people
@@ -55,3 +55,25 @@ const example3 = await people
5555 . execute ( tg ) ;
5656
5757console . log ( "Example 3" , example3 ) ;
58+
59+ // Example 4: Math coverage (https://x.com/dshukertjr/status/1948730454535798799)
60+ import { sin , cos , exp , ln , tan , abs , sqrt } from "typegres" ;
61+ const homework = await values ( {
62+ x : Float8 . new ( 1.5 ) ,
63+ y : Float8 . new ( 0.7 ) ,
64+ } )
65+ . select ( ( { x, y } ) => ( {
66+ result : sin ( x )
67+ [ "+" ] ( cos ( y ) )
68+ [ "/" ] ( ln ( x . power ( 2 ) [ "+" ] ( 1 ) ) [ "+" ] ( 1 ) )
69+ . power ( 2 )
70+ [ "+" ] (
71+ exp ( Float8 . new ( 0 ) [ "-" ] ( y . power ( 2 ) ) ) [ "*" ] (
72+ sqrt ( abs ( tan ( x [ "*" ] ( y ) ) ) [ "+" ] ( 1 ) )
73+ )
74+ ) ,
75+ } ) )
76+ . debug ( )
77+ . execute ( tg ) ;
78+
79+ console . log ( "Example 4" , homework ) ;
0 commit comments