@@ -1090,6 +1090,77 @@ describe("firestore", () => {
10901090 limit ( 25 ) ) ;
10911091 // [END paginate]
10921092 } ) ;
1093+
1094+ it ( "should handle OR queries" , async ( ) => {
1095+ const { collection, query, where, and } = require ( "firebase/firestore" ) ;
1096+ // [START or_query]
1097+ const query = query ( collection ( db , "cities" ) , and (
1098+ where ( 'name' , '>' , 'L' ) ,
1099+ or (
1100+ where ( 'capital' , '==' , true ) ,
1101+ where ( 'population' , '>=' , 1000000 )
1102+ )
1103+ ) ) ;
1104+ // [END or_query]
1105+ } ) ;
1106+
1107+ it ( "should allow for 30 or fewer disjunctions" , async ( ) => {
1108+ const { collection, query, where, and } = require ( "firebase/firestore" ) ;
1109+ const collectionRef = collection ( db , "cities" ) ;
1110+ // [START one_disjunction]
1111+ query ( collectionRef , where ( "a" , "==" , 1 ) ) ;
1112+ // [END one_disjunction]
1113+
1114+ // [START two_disjunctions]
1115+ query ( collectionRef , or ( where ( "a" , "==" , 1 ) , where ( "b" , "==" , 2 ) ) ) ;
1116+ // [END two_disjunctions]
1117+
1118+ // [START four_disjunctions]
1119+ query ( collectionRef ,
1120+ or ( and ( where ( "a" , "==" , 1 ) , where ( "c" , "==" , 3 ) ) ,
1121+ and ( where ( "a" , "==" , 1 ) , where ( "d" , "==" , 4 ) ) ,
1122+ and ( where ( "b" , "==" , 2 ) , where ( "c" , "==" , 3 ) ) ,
1123+ and ( where ( "b" , "==" , 2 ) , where ( "d" , "==" , 4 ) )
1124+ )
1125+ ) ;
1126+ // [END four_disjunctions]
1127+
1128+ // [START four_disjunctions_compact]
1129+ query ( collectionRef ,
1130+ and ( or ( where ( "a" , "==" , 1 ) , where ( "b" , "==" , 2 ) ) ,
1131+ or ( where ( "c" , "==" , 3 ) , where ( "d" , "==" , 4 ) )
1132+ )
1133+ ) ;
1134+ // [END four_disjunctions_compact]
1135+
1136+ expect ( ( ) => {
1137+ // [START 50_disjunctions]
1138+ query ( collectionRef ,
1139+ and ( where ( "a" , "in" , [ 1 , 2 , 3 , 4 , 5 ] ) ,
1140+ where ( "b" , "in" , [ 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 ] )
1141+ )
1142+ ) ;
1143+ // [END 50_disjunctions]
1144+ } ) . to . throw ;
1145+
1146+ // [START 20_disjunctions]
1147+ query ( collectionRef ,
1148+ or ( where ( "a" , "in" , [ 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 ] ) ,
1149+ where ( "b" , "in" , [ 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 ] )
1150+ )
1151+ ) ;
1152+ // [END 20_disjunctions]
1153+
1154+ // [START 10_disjunctions]
1155+ query ( collectionRef ,
1156+ and ( where ( "a" , "in" , [ 1 , 2 , 3 , 4 , 5 ] ) ,
1157+ or ( where ( "b" , "==" , 2 ) ,
1158+ where ( "c" , "==" , 3 )
1159+ )
1160+ )
1161+ ) ;
1162+ // [END 10_disjunctions]
1163+ } ) ;
10931164 } ) ;
10941165
10951166 describe ( 'collectionGroup(landmarks)' , ( ) => {
0 commit comments