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) {
560
560
var citiesRef = db . collection ( 'cities' ) ;
561
561
var query = citiesRef . where ( 'capital' , '==' , true ) . get ( )
562
562
. then ( snapshot => {
563
+ if ( snapshot . empty ) {
564
+ console . log ( 'No matching documents.' ) ;
565
+ return ;
566
+ }
567
+
563
568
snapshot . forEach ( doc => {
564
569
console . log ( doc . id , '=>' , doc . data ( ) ) ;
565
570
} ) ;
@@ -734,7 +739,7 @@ function listenDiffs(db, done) {
734
739
// [START listen_diffs]
735
740
var observer = db . collection ( 'cities' ) . where ( 'state' , '==' , 'CA' )
736
741
. onSnapshot ( querySnapshot => {
737
- querySnapshot . docChanges . forEach ( change => {
742
+ querySnapshot . docChanges ( ) . forEach ( change => {
738
743
if ( change . type === 'added' ) {
739
744
console . log ( 'New city: ' , change . doc . data ( ) ) ;
740
745
}
You can’t perform that action at this time.
0 commit comments