4
4
eq ,
5
5
gt ,
6
6
upper ,
7
+ concat ,
7
8
} from "../../src/query/index.js"
8
9
import { createCollection } from "../../src/collection.js"
9
10
import { mockSyncCollectionOptions } from "../utls.js"
@@ -786,12 +787,12 @@ function createBasicTests(autoIndex: `off` | `eager`) {
786
787
q
787
788
. from ( { user : usersCollection } )
788
789
. where ( ( { user } ) =>
789
- eq ( user . profile . bio , `Software engineer with 5 years experience` )
790
+ eq ( user . profile ? .bio , `Software engineer with 5 years experience` )
790
791
)
791
792
. select ( ( { user } ) => ( {
792
793
id : user . id ,
793
794
name : user . name ,
794
- bio : user . profile . bio ,
795
+ bio : user . profile ? .bio ,
795
796
} ) ) ,
796
797
} )
797
798
@@ -808,11 +809,11 @@ function createBasicTests(autoIndex: `off` | `eager`) {
808
809
query : ( q ) =>
809
810
q
810
811
. from ( { user : usersCollection } )
811
- . where ( ( { user } ) => eq ( user . profile . preferences . theme , `dark` ) )
812
+ . where ( ( { user } ) => eq ( user . profile ? .preferences . theme , `dark` ) )
812
813
. select ( ( { user } ) => ( {
813
814
id : user . id ,
814
815
name : user . name ,
815
- theme : user . profile . preferences . theme ,
816
+ theme : user . profile ? .preferences . theme ,
816
817
} ) ) ,
817
818
} )
818
819
@@ -831,9 +832,9 @@ function createBasicTests(autoIndex: `off` | `eager`) {
831
832
q . from ( { user : usersCollection } ) . select ( ( { user } ) => ( {
832
833
id : user . id ,
833
834
name : user . name ,
834
- preferences : user . profile . preferences ,
835
- city : user . address . city ,
836
- coordinates : user . address . coordinates ,
835
+ preferences : user . profile ? .preferences ,
836
+ city : user . address ? .city ,
837
+ coordinates : user . address ? .coordinates ,
837
838
} ) ) ,
838
839
} )
839
840
@@ -899,8 +900,8 @@ function createBasicTests(autoIndex: `off` | `eager`) {
899
900
q . from ( { user : usersCollection } ) . select ( ( { user } ) => ( {
900
901
id : user . id ,
901
902
name : user . name ,
902
- theme : user . profile . preferences . theme ,
903
- notifications : user . profile . preferences . notifications ,
903
+ theme : user . profile ? .preferences . theme ,
904
+ notifications : user . profile ? .preferences . notifications ,
904
905
} ) ) ,
905
906
} )
906
907
@@ -991,10 +992,10 @@ function createBasicTests(autoIndex: `off` | `eager`) {
991
992
q . from ( { user : usersCollection } ) . select ( ( { user } ) => ( {
992
993
id : user . id ,
993
994
name : user . name ,
994
- street : user . address . street ,
995
- city : user . address . city ,
996
- country : user . address . country ,
997
- coordinates : user . address . coordinates ,
995
+ street : user . address ? .street ,
996
+ city : user . address ? .city ,
997
+ country : user . address ? .country ,
998
+ coordinates : user . address ? .coordinates ,
998
999
} ) ) ,
999
1000
} )
1000
1001
@@ -1021,12 +1022,12 @@ function createBasicTests(autoIndex: `off` | `eager`) {
1021
1022
query : ( q ) =>
1022
1023
q
1023
1024
. from ( { user : usersCollection } )
1024
- . where ( ( { user } ) => eq ( user . address . city , `New York` ) )
1025
+ . where ( ( { user } ) => eq ( user . address ? .city , `New York` ) )
1025
1026
. select ( ( { user } ) => ( {
1026
1027
id : user . id ,
1027
1028
name : user . name ,
1028
- lat : user . address . coordinates . lat ,
1029
- lng : user . address . coordinates . lng ,
1029
+ lat : user . address ? .coordinates . lat ,
1030
+ lng : user . address ? .coordinates . lng ,
1030
1031
} ) ) ,
1031
1032
} )
1032
1033
@@ -1044,11 +1045,11 @@ function createBasicTests(autoIndex: `off` | `eager`) {
1044
1045
query : ( q ) =>
1045
1046
q
1046
1047
. from ( { user : usersCollection } )
1047
- . where ( ( { user } ) => gt ( user . address . coordinates . lat , 38 ) )
1048
+ . where ( ( { user } ) => gt ( user . address ? .coordinates . lat , 38 ) )
1048
1049
. select ( ( { user } ) => ( {
1049
1050
id : user . id ,
1050
1051
name : user . name ,
1051
- city : user . address . city ,
1052
+ city : user . address ? .city ,
1052
1053
} ) ) ,
1053
1054
} )
1054
1055
@@ -1067,10 +1068,10 @@ function createBasicTests(autoIndex: `off` | `eager`) {
1067
1068
q . from ( { user : usersCollection } ) . select ( ( { user } ) => ( {
1068
1069
id : user . id ,
1069
1070
name : user . name ,
1070
- city : user . address . city ,
1071
- country : user . address . country ,
1072
- hasNotifications : user . profile . preferences . notifications ,
1073
- profileSummary : concat ( upper ( user . name ) , ` - ` , user . profile . bio ) ,
1071
+ city : user . address ? .city ,
1072
+ country : user . address ? .country ,
1073
+ hasNotifications : user . profile ? .preferences . notifications ,
1074
+ profileSummary : concat ( upper ( user . name ) , ` - ` , user . profile ? .bio ) ,
1074
1075
} ) ) ,
1075
1076
} )
1076
1077
0 commit comments