@@ -39,6 +39,14 @@ describe("firestore", () => {
39
39
// [END initialize_persistence]
40
40
} ) ;
41
41
42
+ it ( "should be able to set the cache size" , ( ) => {
43
+ // [START fs_setup_cache]
44
+ firebase . firestore ( ) . settings ( {
45
+ cacheSizeBytes : firebase . firestore . CACHE_SIZE_UNLIMITED
46
+ } ) ;
47
+ // [END fs_setup_cache]
48
+ } ) ;
49
+
42
50
it ( "should be able to enable/disable network" , ( ) => {
43
51
var disable =
44
52
// [START disable_network]
@@ -928,6 +936,69 @@ describe("firestore", () => {
928
936
// [END paginate]
929
937
} ) ;
930
938
} ) ;
939
+
940
+ describe ( 'collectionGroup(landmarks' , ( ) => {
941
+ it ( "should setup example data" , ( ) => {
942
+ // [START fs_collection_group_query_data_setup]
943
+ var citiesRef = db . collection ( 'cities' ) ;
944
+
945
+ var landmarks = Promise . all ( [
946
+ citiesRef . doc ( 'SF' ) . collection ( 'landmarks' ) . doc ( ) . set ( {
947
+ name : 'Golden Gate Bridge' ,
948
+ type : 'bridge'
949
+ } ) ,
950
+ citiesRef . doc ( 'SF' ) . collection ( 'landmarks' ) . doc ( ) . set ( {
951
+ name : 'Legion of Honor' ,
952
+ type : 'museum'
953
+ } ) ,
954
+ citiesRef . doc ( 'LA' ) . collection ( 'landmarks' ) . doc ( ) . set ( {
955
+ name : 'Griffith Park' ,
956
+ type : 'park'
957
+ } ) ,
958
+ citiesRef . doc ( 'LA' ) . collection ( 'landmarks' ) . doc ( ) . set ( {
959
+ name : 'The Getty' ,
960
+ type : 'museum'
961
+ } ) ,
962
+ citiesRef . doc ( 'DC' ) . collection ( 'landmarks' ) . doc ( ) . set ( {
963
+ name : 'Lincoln Memorial' ,
964
+ type : 'memorial'
965
+ } ) ,
966
+ citiesRef . doc ( 'DC' ) . collection ( 'landmarks' ) . doc ( ) . set ( {
967
+ name : 'National Air and Space Museum' ,
968
+ type : 'museum'
969
+ } ) ,
970
+ citiesRef . doc ( 'TOK' ) . collection ( 'landmarks' ) . doc ( ) . set ( {
971
+ name : 'Ueno Park' ,
972
+ type : 'park'
973
+ } ) ,
974
+ citiesRef . doc ( 'TOK' ) . collection ( 'landmarks' ) . doc ( ) . set ( {
975
+ name : 'National Museum of Nature and Science' ,
976
+ type : 'museum'
977
+ } ) ,
978
+ citiesRef . doc ( 'BJ' ) . collection ( 'landmarks' ) . doc ( ) . set ( {
979
+ name : 'Jingshan Park' ,
980
+ type : 'park'
981
+ } ) ,
982
+ citiesRef . doc ( 'BJ' ) . collection ( 'landmarks' ) . doc ( ) . set ( {
983
+ name : 'Beijing Ancient Observatory' ,
984
+ type : 'museum'
985
+ } )
986
+ ] ) ;
987
+ // [END fs_collection_group_query_data_setup]
988
+ return landmarks ;
989
+ } ) ;
990
+
991
+ it ( "should query a collection group" , ( ) => {
992
+ // [START fs_collection_group_query]
993
+ var museums = db . collectionGroup ( 'landmarks' ) . where ( 'type' , '==' , 'museum' ) ;
994
+ museums . get ( ) . then ( function ( querySnapshot ) {
995
+ querySnapshot . forEach ( function ( doc ) {
996
+ console . log ( doc . id , ' => ' , doc . data ( ) ) ;
997
+ } ) ;
998
+ } ) ;
999
+ // [END fs_collection_group_query]
1000
+ } ) ;
1001
+ } ) ;
931
1002
} ) ;
932
1003
933
1004
// TODO: Break out into separate file
0 commit comments