File tree Expand file tree Collapse file tree 1 file changed +6
-1
lines changed
Expand file tree Collapse file tree 1 file changed +6
-1
lines changed Original file line number Diff line number Diff line change @@ -560,6 +560,11 @@ function getMultiple(db) {
560560 var citiesRef = db . collection ( 'cities' ) ;
561561 var query = citiesRef . where ( 'capital' , '==' , true ) . get ( )
562562 . then ( snapshot => {
563+ if ( snapshot . empty ) {
564+ console . log ( 'No matching documents.' ) ;
565+ return ;
566+ }
567+
563568 snapshot . forEach ( doc => {
564569 console . log ( doc . id , '=>' , doc . data ( ) ) ;
565570 } ) ;
@@ -734,7 +739,7 @@ function listenDiffs(db, done) {
734739 // [START listen_diffs]
735740 var observer = db . collection ( 'cities' ) . where ( 'state' , '==' , 'CA' )
736741 . onSnapshot ( querySnapshot => {
737- querySnapshot . docChanges . forEach ( change => {
742+ querySnapshot . docChanges ( ) . forEach ( change => {
738743 if ( change . type === 'added' ) {
739744 console . log ( 'New city: ' , change . doc . data ( ) ) ;
740745 }
You can’t perform that action at this time.
0 commit comments