[firestore] Add support for `GetOptions` #1248

This commit is contained in:
Chris Bianca 2018-07-03 16:03:43 +01:00
parent 43615ffcf6
commit a79bf81418
23 changed files with 2829 additions and 2610 deletions

View File

@ -83,14 +83,14 @@ dependencies {
}
compileOnly "com.google.android.gms:play-services-base:15.0.1"
compileOnly "com.google.firebase:firebase-ads:15.0.1"
compileOnly "com.google.firebase:firebase-auth:16.0.1"
compileOnly "com.google.firebase:firebase-auth:16.0.2"
compileOnly "com.google.firebase:firebase-config:16.0.0"
compileOnly "com.google.firebase:firebase-core:16.0.0"
compileOnly "com.google.firebase:firebase-crash:16.0.0"
compileOnly "com.google.firebase:firebase-core:16.0.1"
compileOnly "com.google.firebase:firebase-crash:16.0.1"
compileOnly "com.google.firebase:firebase-database:16.0.1"
compileOnly "com.google.firebase:firebase-firestore:17.0.1"
compileOnly "com.google.firebase:firebase-firestore:17.0.2"
compileOnly "com.google.firebase:firebase-functions:16.0.1"
compileOnly "com.google.firebase:firebase-invites:16.0.0"
compileOnly "com.google.firebase:firebase-invites:16.0.1"
compileOnly "com.google.firebase:firebase-storage:16.0.1"
compileOnly "com.google.firebase:firebase-messaging:17.0.0"
compileOnly "com.google.firebase:firebase-perf:16.0.0"

View File

@ -91,9 +91,10 @@ public class RNFirebaseFirestore extends ReactContextBaseJavaModule {
@ReactMethod
public void collectionGet(String appName, String path, ReadableArray filters,
ReadableArray orders, ReadableMap options, final Promise promise) {
ReadableArray orders, ReadableMap options, ReadableMap getOptions,
final Promise promise) {
RNFirebaseFirestoreCollectionReference ref = getCollectionForAppPath(appName, path, filters, orders, options);
ref.get(promise);
ref.get(getOptions, promise);
}
@ReactMethod
@ -165,14 +166,9 @@ public class RNFirebaseFirestore extends ReactContextBaseJavaModule {
}
@ReactMethod
public void documentGet(String appName, String path, final Promise promise) {
public void documentGet(String appName, String path, ReadableMap getOptions, final Promise promise) {
RNFirebaseFirestoreDocumentReference ref = getDocumentForAppPath(appName, path);
ref.get(promise);
}
@ReactMethod
public void documentGetAll(String appName, ReadableArray documents, final Promise promise) {
// Not supported on Android out of the box
ref.get(getOptions, promise);
}
@ReactMethod

View File

@ -20,6 +20,7 @@ import com.google.firebase.firestore.ListenerRegistration;
import com.google.firebase.firestore.MetadataChanges;
import com.google.firebase.firestore.Query;
import com.google.firebase.firestore.QuerySnapshot;
import com.google.firebase.firestore.Source;
import java.util.ArrayList;
import java.util.HashMap;
@ -52,8 +53,21 @@ public class RNFirebaseFirestoreCollectionReference {
this.reactContext = reactContext;
}
void get(final Promise promise) {
query.get().addOnCompleteListener(new OnCompleteListener<QuerySnapshot>() {
void get(ReadableMap getOptions, final Promise promise) {
Source source;
if (getOptions != null && getOptions.hasKey("source")) {
String optionsSource = getOptions.getString("source");
if ("server".equals(optionsSource)) {
source = Source.SERVER;
} else if ("cache".equals(optionsSource)) {
source = Source.CACHE;
} else {
source = Source.DEFAULT;
}
} else {
source = Source.DEFAULT;
}
query.get(source).addOnCompleteListener(new OnCompleteListener<QuerySnapshot>() {
@Override
public void onComplete(@NonNull Task<QuerySnapshot> task) {
if (task.isSuccessful()) {

View File

@ -17,6 +17,7 @@ import com.google.firebase.firestore.FirebaseFirestoreException;
import com.google.firebase.firestore.ListenerRegistration;
import com.google.firebase.firestore.MetadataChanges;
import com.google.firebase.firestore.SetOptions;
import com.google.firebase.firestore.Source;
import java.util.HashMap;
import java.util.Map;
@ -55,8 +56,21 @@ public class RNFirebaseFirestoreDocumentReference {
});
}
void get(final Promise promise) {
this.ref.get().addOnCompleteListener(new OnCompleteListener<DocumentSnapshot>() {
void get(final ReadableMap getOptions, final Promise promise) {
Source source;
if (getOptions != null && getOptions.hasKey("source")) {
String optionsSource = getOptions.getString("source");
if ("server".equals(optionsSource)) {
source = Source.SERVER;
} else if ("cache".equals(optionsSource)) {
source = Source.CACHE;
} else {
source = Source.DEFAULT;
}
} else {
source = Source.DEFAULT;
}
this.ref.get(source).addOnCompleteListener(new OnCompleteListener<DocumentSnapshot>() {
@Override
public void onComplete(@NonNull Task<DocumentSnapshot> task) {
if (task.isSuccessful()) {

View File

@ -92,18 +92,18 @@ dependencies {
}
// RNFirebase required dependencies
implementation "com.google.firebase:firebase-core:16.0.0"
implementation "com.google.firebase:firebase-core:16.0.1"
implementation "com.google.android.gms:play-services-base:15.0.1"
// RNFirebase optional dependencies
implementation "com.google.firebase:firebase-ads:15.0.1"
implementation "com.google.firebase:firebase-auth:16.0.1"
implementation "com.google.firebase:firebase-auth:16.0.2"
implementation "com.google.firebase:firebase-config:16.0.0"
implementation "com.google.firebase:firebase-crash:16.0.0"
implementation "com.google.firebase:firebase-crash:16.0.1"
implementation "com.google.firebase:firebase-database:16.0.1"
implementation "com.google.firebase:firebase-firestore:17.0.1"
implementation "com.google.firebase:firebase-firestore:17.0.2"
implementation "com.google.firebase:firebase-functions:16.0.1"
implementation "com.google.firebase:firebase-invites:16.0.0"
implementation "com.google.firebase:firebase-invites:16.0.1"
implementation "com.google.firebase:firebase-storage:16.0.1"
implementation "com.google.firebase:firebase-messaging:17.0.0"
implementation "com.google.firebase:firebase-perf:16.0.0"

View File

@ -122,6 +122,52 @@ describe('firestore()', () => {
documentSnapshot.should.be.instanceOf(DocumentSnapshot);
});
});
it('should support GetOptions source=`default`', async () => {
const collection = testCollection(TEST_COLLECTION_NAME);
const querySnapshot = await collection.get({ source: 'default' });
should.equal(querySnapshot.size >= 1, true);
querySnapshot.metadata.should.be.an.Object();
should.equal(querySnapshot.metadata.fromCache, false);
});
it('should support GetOptions source=`server`', async () => {
const collection = testCollection(TEST_COLLECTION_NAME);
const querySnapshot = await collection.get({ source: 'server' });
should.equal(querySnapshot.size >= 1, true);
querySnapshot.metadata.should.be.an.Object();
should.equal(querySnapshot.metadata.fromCache, false);
});
// TODO: Investigate why this isn't returning `fromCache=true`
xit('should support GetOptions source=`cache`', async () => {
const collection = testCollection(TEST_COLLECTION_NAME);
const querySnapshot = await collection.get({ source: 'cache' });
should.equal(querySnapshot.size >= 1, true);
querySnapshot.metadata.should.be.an.Object();
should.equal(querySnapshot.metadata.fromCache, true);
});
it('should error with invalid GetOptions source option', async () => {
const collectionRef = testCollection(TEST_COLLECTION_NAME);
try {
await collectionRef.get(() => {});
return Promise.reject(
new Error('get() did not reject with invalid argument.')
);
} catch (e) {
// do nothing
}
try {
await collectionRef.get({ source: 'invalid' });
return Promise.reject(
new Error('get() did not reject with invalid source property.')
);
} catch (e) {
// do nothing
}
return Promise.resolve();
});
});
describe('onSnapshot()', () => {

View File

@ -67,6 +67,62 @@ describe('firestore()', () => {
snapshot.id.should.equal(COL2_DOC_1_ID);
snapshot.metadata.should.be.an.Object();
});
it('should support GetOptions source=`default`', async () => {
await resetTestCollectionDoc(COL2_DOC_1_PATH, COL2_DOC_1());
const snapshot = await test2DocRef(COL2_DOC_1_ID).get({
source: 'default',
});
snapshot.id.should.equal(COL2_DOC_1_ID);
snapshot.metadata.should.be.an.Object();
should.equal(snapshot.metadata.fromCache, false);
});
it('should support GetOptions source=`server`', async () => {
await resetTestCollectionDoc(COL2_DOC_1_PATH, COL2_DOC_1());
const snapshot = await test2DocRef(COL2_DOC_1_ID).get({
source: 'server',
});
snapshot.id.should.equal(COL2_DOC_1_ID);
snapshot.metadata.should.be.an.Object();
should.equal(snapshot.metadata.fromCache, false);
});
// TODO: For some reason when using `cache` it's not seeing the data as available, even if
// first requesting it from the server, although interestingly it works fine in the old
// tests app
xit('should support GetOptions source=`cache`', async () => {
await resetTestCollectionDoc(COL2_DOC_1_PATH, COL2_DOC_1());
const ref = test2DocRef(COL2_DOC_1_ID);
// Make sure the reference data is populated in the cache
await ref.get({ source: 'server' });
// Retrieve the cached version
const snapshot = await ref.get({ source: 'cache' });
snapshot.id.should.equal(COL2_DOC_1_ID);
snapshot.metadata.should.be.an.Object();
should.equal(snapshot.metadata.fromCache, true);
});
it('should error with invalid GetOptions source option', async () => {
const docRef = test2DocRef(COL2_DOC_1_ID);
try {
await docRef.get(() => {});
return Promise.reject(
new Error('get() did not reject with invalid argument.')
);
} catch (e) {
// do nothing
}
try {
await docRef.get({ source: 'invalid' });
return Promise.reject(
new Error('get() did not reject with invalid source property.')
);
} catch (e) {
// do nothing
}
return Promise.resolve();
});
});
describe('onSnapshot()', () => {

View File

@ -1,66 +1,66 @@
PODS:
- BoringSSL (10.0.2):
- BoringSSL/Implementation (= 10.0.2)
- BoringSSL/Interface (= 10.0.2)
- BoringSSL/Implementation (10.0.2):
- BoringSSL/Interface (= 10.0.2)
- BoringSSL/Interface (10.0.2)
- Crashlytics (3.10.1):
- Fabric (~> 1.7.5)
- Fabric (1.7.6)
- Firebase/AdMob (5.0.1):
- BoringSSL (10.0.5):
- BoringSSL/Implementation (= 10.0.5)
- BoringSSL/Interface (= 10.0.5)
- BoringSSL/Implementation (10.0.5):
- BoringSSL/Interface (= 10.0.5)
- BoringSSL/Interface (10.0.5)
- Crashlytics (3.10.2):
- Fabric (~> 1.7.7)
- Fabric (1.7.7)
- Firebase/AdMob (5.3.0):
- Firebase/Core
- Google-Mobile-Ads-SDK (= 7.30.0)
- Firebase/Auth (5.0.1):
- Google-Mobile-Ads-SDK (= 7.31.0)
- Firebase/Auth (5.3.0):
- Firebase/CoreOnly
- FirebaseAuth (= 5.0.0)
- Firebase/Core (5.0.1):
- FirebaseAuth (= 5.0.1)
- Firebase/Core (5.3.0):
- Firebase/CoreOnly
- FirebaseAnalytics (= 5.0.0)
- Firebase/CoreOnly (5.0.1):
- FirebaseCore (= 5.0.1)
- Firebase/Crash (5.0.1):
- FirebaseAnalytics (= 5.0.1)
- Firebase/CoreOnly (5.3.0):
- FirebaseCore (= 5.0.4)
- Firebase/Crash (5.3.0):
- Firebase/Core
- FirebaseCrash (= 3.0.0)
- Firebase/Database (5.0.1):
- Firebase/Database (5.3.0):
- Firebase/CoreOnly
- FirebaseDatabase (= 5.0.0)
- Firebase/DynamicLinks (5.0.1):
- FirebaseDatabase (= 5.0.1)
- Firebase/DynamicLinks (5.3.0):
- Firebase/Core
- FirebaseDynamicLinks (= 3.0.0)
- Firebase/Firestore (5.0.1):
- FirebaseDynamicLinks (= 3.0.1)
- Firebase/Firestore (5.3.0):
- Firebase/CoreOnly
- FirebaseFirestore (= 0.12.1)
- Firebase/Functions (5.0.1):
- FirebaseFirestore (= 0.12.4)
- Firebase/Functions (5.3.0):
- Firebase/CoreOnly
- FirebaseFunctions (= 2.0.0)
- Firebase/Invites (5.0.1):
- Firebase/Invites (5.3.0):
- Firebase/Core
- FirebaseInvites (= 3.0.0)
- Firebase/Messaging (5.0.1):
- Firebase/Messaging (5.3.0):
- Firebase/CoreOnly
- FirebaseMessaging (= 3.0.0)
- Firebase/Performance (5.0.1):
- FirebaseMessaging (= 3.0.2)
- Firebase/Performance (5.3.0):
- Firebase/Core
- FirebasePerformance (= 2.0.0)
- Firebase/RemoteConfig (5.0.1):
- FirebasePerformance (= 2.0.1)
- Firebase/RemoteConfig (5.3.0):
- Firebase/Core
- FirebaseRemoteConfig (= 3.0.0)
- Firebase/Storage (5.0.1):
- Firebase/Storage (5.3.0):
- Firebase/CoreOnly
- FirebaseStorage (= 3.0.0)
- FirebaseABTesting (2.0.0):
- FirebaseCore (~> 5.0)
- Protobuf (~> 3.5)
- FirebaseAnalytics (5.0.0):
- FirebaseAnalytics (5.0.1):
- FirebaseCore (~> 5.0)
- FirebaseInstanceID (~> 3.0)
- GoogleToolboxForMac/NSData+zlib (~> 2.1)
- nanopb (~> 0.3)
- FirebaseAuth (5.0.0):
- FirebaseAuth (5.0.1):
- FirebaseCore (~> 5.0)
- GTMSessionFetcher/Core (~> 1.1)
- FirebaseCore (5.0.1):
- FirebaseCore (5.0.4):
- GoogleToolboxForMac/NSData+zlib (~> 2.1)
- FirebaseCrash (3.0.0):
- FirebaseAnalytics (~> 5.0)
@ -68,18 +68,18 @@ PODS:
- GoogleToolboxForMac/Logger (~> 2.1)
- GoogleToolboxForMac/NSData+zlib (~> 2.1)
- Protobuf (~> 3.5)
- FirebaseDatabase (5.0.0):
- FirebaseDatabase (5.0.1):
- FirebaseCore (~> 5.0)
- leveldb-library (~> 1.18)
- FirebaseDynamicLinks (3.0.0):
- FirebaseDynamicLinks (3.0.1):
- FirebaseAnalytics (~> 5.0)
- FirebaseFirestore (0.12.1):
- FirebaseFirestore (0.12.4):
- FirebaseCore (~> 5.0)
- FirebaseFirestore/abseil-cpp (= 0.12.1)
- FirebaseFirestore/abseil-cpp (= 0.12.4)
- gRPC-ProtoRPC (~> 1.0)
- leveldb-library (~> 1.18)
- Protobuf (~> 3.1)
- FirebaseFirestore/abseil-cpp (0.12.1):
- FirebaseFirestore/abseil-cpp (0.12.4):
- FirebaseCore (~> 5.0)
- gRPC-ProtoRPC (~> 1.0)
- leveldb-library (~> 1.18)
@ -87,7 +87,7 @@ PODS:
- FirebaseFunctions (2.0.0):
- FirebaseCore (~> 5.0)
- GTMSessionFetcher/Core (~> 1.1)
- FirebaseInstanceID (3.0.0):
- FirebaseInstanceID (3.1.1):
- FirebaseCore (~> 5.0)
- FirebaseInvites (3.0.0):
- FirebaseAnalytics (~> 5.0)
@ -103,14 +103,14 @@ PODS:
- GTMSessionFetcher/Core (~> 1.1)
- GTMSessionFetcher/Full (~> 1.1)
- Protobuf (~> 3.5)
- FirebaseMessaging (3.0.0):
- FirebaseMessaging (3.0.2):
- FirebaseCore (~> 5.0)
- FirebaseInstanceID (~> 3.0)
- GoogleToolboxForMac/Logger (~> 2.1)
- Protobuf (~> 3.1)
- FirebasePerformance (2.0.0):
- FirebasePerformance (2.0.1):
- FirebaseAnalytics (~> 5.0)
- FirebaseInstanceID (~> 3.0)
- FirebaseInstanceID (~> 3.1)
- FirebaseSwizzlingUtilities/ISASwizzling (~> 2.0)
- FirebaseSwizzlingUtilities/MethodSwizzling (~> 2.0)
- GoogleToolboxForMac/Logger (~> 2.1)
@ -130,7 +130,7 @@ PODS:
- FirebaseSwizzlingUtilities/ISASwizzling (2.0.0)
- FirebaseSwizzlingUtilities/MethodSwizzling (2.0.0):
- FirebaseCore (~> 5.0)
- Google-Mobile-Ads-SDK (7.30.0)
- Google-Mobile-Ads-SDK (7.31.0)
- GoogleAPIClientForREST (1.3.4):
- GoogleAPIClientForREST/Core (= 1.3.4)
- GTMSessionFetcher (>= 1.1.7)
@ -162,25 +162,25 @@ PODS:
- GoogleToolboxForMac/Defines (= 2.1.4)
- GoogleToolboxForMac/NSDictionary+URLArguments (= 2.1.4)
- GoogleToolboxForMac/NSString+URLArguments (= 2.1.4)
- gRPC (1.11.0):
- gRPC-RxLibrary (= 1.11.0)
- gRPC/Main (= 1.11.0)
- gRPC-Core (1.11.0):
- gRPC-Core/Implementation (= 1.11.0)
- gRPC-Core/Interface (= 1.11.0)
- gRPC-Core/Implementation (1.11.0):
- gRPC (1.12.0):
- gRPC-RxLibrary (= 1.12.0)
- gRPC/Main (= 1.12.0)
- gRPC-Core (1.12.0):
- gRPC-Core/Implementation (= 1.12.0)
- gRPC-Core/Interface (= 1.12.0)
- gRPC-Core/Implementation (1.12.0):
- BoringSSL (~> 10.0)
- gRPC-Core/Interface (= 1.11.0)
- gRPC-Core/Interface (= 1.12.0)
- nanopb (~> 0.3)
- gRPC-Core/Interface (1.11.0)
- gRPC-ProtoRPC (1.11.0):
- gRPC (= 1.11.0)
- gRPC-RxLibrary (= 1.11.0)
- gRPC-Core/Interface (1.12.0)
- gRPC-ProtoRPC (1.12.0):
- gRPC (= 1.12.0)
- gRPC-RxLibrary (= 1.12.0)
- Protobuf (~> 3.0)
- gRPC-RxLibrary (1.11.0)
- gRPC/Main (1.11.0):
- gRPC-Core (= 1.11.0)
- gRPC-RxLibrary (= 1.11.0)
- gRPC-RxLibrary (1.12.0)
- gRPC/Main (1.12.0):
- gRPC-Core (= 1.12.0)
- gRPC-RxLibrary (= 1.12.0)
- GTMOAuth2 (1.1.6):
- GTMSessionFetcher (~> 1.1)
- GTMSessionFetcher (1.1.15):
@ -194,7 +194,7 @@ PODS:
- nanopb/encode (= 0.3.8)
- nanopb/decode (0.3.8)
- nanopb/encode (0.3.8)
- Protobuf (3.5.0)
- Protobuf (3.6.0)
- React (0.55.3):
- React/Core (= 0.55.3)
- React/Core (0.55.3):
@ -210,7 +210,7 @@ PODS:
- React/Core
- React/fishhook
- React/RCTBlob
- RNFirebase (4.1.0):
- RNFirebase (4.2.0):
- Firebase/Core
- React
- yoga (0.55.3.React)
@ -247,39 +247,39 @@ EXTERNAL SOURCES:
:path: ../node_modules/react-native/ReactCommon/yoga
SPEC CHECKSUMS:
BoringSSL: 60dd24df4af296bf41d78e5841dbb95d75f88c0d
Crashlytics: aee1a064cbbf99b32efa3f056a5f458d846bc8ff
Fabric: f8d42c893bb187326a7968b62abe55c36a987a46
Firebase: d6861c2059d8c32d1e6dd8932e22ada346d90a3a
BoringSSL: cf3f1793eb6e3c445c4d150456341f149c268a35
Crashlytics: 0360624eea1c978a743feddb2fb1ef8b37fb7a0d
Fabric: bda89e242bce1b7b8ab264248cf3407774ce0095
Firebase: 68afeeb05461db02d7c9e3215cda28068670f4aa
FirebaseABTesting: 1f50b8d50f5e3469eea54e7463a7b7fe221d1f5e
FirebaseAnalytics: 19812b49fa5f283dd6b23edf8a14b5d477029ab8
FirebaseAuth: acbeef02fe7c3a26624e309849f3fe30c84115af
FirebaseCore: cafc814b2d84fc8733f09e653041cc2165332ad7
FirebaseAnalytics: b3628aea54c50464c32c393fb2ea032566e7ecc2
FirebaseAuth: 463b8ce33bd5d05f706dcd4615499e3212b4132b
FirebaseCore: 62f1b792a49bb9e8b4073f24606d2c93ffc352f0
FirebaseCrash: 8900571fd763fd5bdda04522ec53da979456e3ce
FirebaseDatabase: 697eb53e5b4fe7cd4fa8756c1f82a9fca011345f
FirebaseDynamicLinks: c70e8ef2f267f13459db89b8816b13a06b2278d2
FirebaseFirestore: f686b8e83f3cf8bbc37db6e98e01029a14f01f55
FirebaseDatabase: 482bad9c2abd422bb2321194fb8c937e67426a89
FirebaseDynamicLinks: d624a7adc81a8fd70d52be5a6a47a2bc0644b923
FirebaseFirestore: 53f6fe858494c39dbfd5237655e0641152a88c89
FirebaseFunctions: 141da172b7491276d9da8715b8ca88f9e439ffb6
FirebaseInstanceID: 83e0040351565df711a5db3d8ebe5ea21aca998a
FirebaseInstanceID: f3f0657372592ecdfdfe2cac604a5a75758376a6
FirebaseInvites: d7534f94d0610b892bac8ee0cf4218a14be46c28
FirebaseMessaging: f2360a966ecfb0d14facf0fbdf306efc2df0ddbe
FirebasePerformance: 1ec6c40e5dad2543ca4c4f25d15168bde6322c2c
FirebaseMessaging: 6894b8fe0a0cf26c3b13dad729f1131654ae0bdb
FirebasePerformance: 1ebd87ffee5ca814582db1dc9e25651792ba02db
FirebaseRemoteConfig: 3c57e4644bd6976b671ae0b725cd709f198bd1f5
FirebaseStorage: 7ca4bb7b58a25fa647b04f524033fc7cb7eb272b
FirebaseSwizzlingUtilities: 6c22677c50d0b6f5f0dc637c1233f13694a3003f
Google-Mobile-Ads-SDK: 7404f68120ae8682afeb5af001fbf4aad731c78e
Google-Mobile-Ads-SDK: 6e529e748b45507a2ca904e0b5a52669ba3920c4
GoogleAPIClientForREST: f7951c455df271bc6259b3ddb4073d0026475ccf
GoogleSignIn: d9ef55b10f0aa401a5de2747f59b725e4b9732ac
GoogleToolboxForMac: 91c824d21e85b31c2aae9bb011c5027c9b4e738f
gRPC: 70703dc9ba31c72341fc7f37745cc1c379edee96
gRPC-Core: 164639cd8ae18ca8b65477fafb2efbaecf4f181a
gRPC-ProtoRPC: bb5fddf3424aa4fad74d76736578a79fe40e244e
gRPC-RxLibrary: 26d53d1b1f306befd4ad4e15bd6de27839a82481
gRPC: 9362451032695e2dfb7bafcd3740e3a27939e4ff
gRPC-Core: 9696b220565b283e021cf2722d473a4a74b7622a
gRPC-ProtoRPC: a1bd56fb1991a8dae4581250d7259eddabb66779
gRPC-RxLibrary: 1ed5314e8b38cd6e55c9bfa048387136ae925ce9
GTMOAuth2: c77fe325e4acd453837e72d91e3b5f13116857b2
GTMSessionFetcher: 5fa5b80fd20e439ef5f545fb2cb3ca6c6714caa2
leveldb-library: 08cba283675b7ed2d99629a4bc5fd052cd2bb6a5
nanopb: 5601e6bca2dbf1ed831b519092ec110f66982ca3
Protobuf: 8a9838fba8dae3389230e1b7f8c104aa32389c03
Protobuf: 0fc0ad8bec688b2a3017a139953e01374fedbd5f
React: aa2040dbb6f317b95314968021bd2888816e03d5
RNFirebase: 2b25fd2e60269f26bb0a76c71dcc942b35a77df0
yoga: a23273df0088bf7f2bb7e5d7b00044ea57a2a54a

View File

@ -236,9 +236,10 @@ RCT_EXPORT_METHOD(collectionGet:(NSString *)appDisplayName
filters:(NSArray *)filters
orders:(NSArray *)orders
options:(NSDictionary *)options
getOptions:(NSDictionary *)getOptions
resolver:(RCTPromiseResolveBlock)resolve
rejecter:(RCTPromiseRejectBlock)reject) {
[[self getCollectionForAppPath:appDisplayName path:path filters:filters orders:orders options:options] get:resolve rejecter:reject];
[[self getCollectionForAppPath:appDisplayName path:path filters:filters orders:orders options:options] get:getOptions resolver:resolve rejecter:reject];
}
RCT_EXPORT_METHOD(collectionOffSnapshot:(NSString *)appDisplayName
@ -307,16 +308,10 @@ RCT_EXPORT_METHOD(documentDelete:(NSString *)appDisplayName
RCT_EXPORT_METHOD(documentGet:(NSString *)appDisplayName
path:(NSString *)path
getOptions:(NSDictionary *)getOptions
resolver:(RCTPromiseResolveBlock)resolve
rejecter:(RCTPromiseRejectBlock)reject) {
[[self getDocumentForAppPath:appDisplayName path:path] get:resolve rejecter:reject];
}
RCT_EXPORT_METHOD(documentGetAll:(NSString *)appDisplayName
documents:(NSString *)documents
resolver:(RCTPromiseResolveBlock)resolve
rejecter:(RCTPromiseRejectBlock)reject) {
// Not supported on iOS out of the box
[[self getDocumentForAppPath:appDisplayName path:path] get:getOptions resolver:resolve rejecter:reject];
}
RCT_EXPORT_METHOD(documentOffSnapshot:(NSString *)appDisplayName
@ -356,10 +351,10 @@ RCT_EXPORT_METHOD(settings:(NSString *)appDisplayName
rejecter:(RCTPromiseRejectBlock)reject) {
FIRFirestore *firestore = [RNFirebaseFirestore getFirestoreForApp:appDisplayName];
FIRFirestoreSettings *firestoreSettings = [[FIRFirestoreSettings alloc] init];
// Make sure the dispatch queue is set correctly
firestoreSettings.dispatchQueue = firestoreQueue;
// Apply the settings passed by the user, or ensure that the current settings are preserved
if (settings[@"host"]) {
firestoreSettings.host = settings[@"host"];
@ -396,7 +391,7 @@ RCT_EXPORT_METHOD(settings:(NSString *)appDisplayName
+ (FIRFirestore *)getFirestoreForApp:(NSString *)appDisplayName {
FIRApp *app = [RNFirebaseUtil getApp:appDisplayName];
FIRFirestore *firestore = [FIRFirestore firestoreForApp:app];
// This is the first time we've tried to do something on this Firestore instance
// So we need to make sure the dispatch queue is set correctly
if (!initialisedApps[appDisplayName]) {
@ -529,4 +524,3 @@ RCT_EXPORT_METHOD(settings:(NSString *)appDisplayName
@implementation RNFirebaseFirestore
@end
#endif

View File

@ -21,7 +21,7 @@
@property FIRQuery *query;
- (id)initWithPathAndModifiers:(RCTEventEmitter *)emitter appDisplayName:(NSString *)appDisplayName path:(NSString *)path filters:(NSArray *)filters orders:(NSArray *)orders options:(NSDictionary *)options;
- (void)get:(RCTPromiseResolveBlock) resolve rejecter:(RCTPromiseRejectBlock) reject;
- (void)get:(NSDictionary *)getOptions resolver:(RCTPromiseResolveBlock) resolve rejecter:(RCTPromiseRejectBlock) reject;
+ (void)offSnapshot:(NSString *)listenerId;
- (void)onSnapshot:(NSString *)listenerId queryListenOptions:(NSDictionary *) queryListenOptions;
+ (NSDictionary *)snapshotToDictionary:(FIRQuerySnapshot *)querySnapshot;

View File

@ -29,9 +29,22 @@ static NSMutableDictionary *_listeners;
return self;
}
- (void)get:(RCTPromiseResolveBlock) resolve
- (void)get:(NSDictionary *) getOptions
resolver:(RCTPromiseResolveBlock) resolve
rejecter:(RCTPromiseRejectBlock) reject {
[_query getDocumentsWithCompletion:^(FIRQuerySnapshot * _Nullable snapshot, NSError * _Nullable error) {
FIRFirestoreSource source;
if (getOptions && getOptions[@"source"]) {
if ([getOptions[@"source"] isEqualToString:@"server"]) {
source = FIRFirestoreSourceServer;
} else if ([getOptions[@"source"] isEqualToString:@"cache"]) {
source = FIRFirestoreSourceCache;
} else {
source = FIRFirestoreSourceDefault;
}
} else {
source = FIRFirestoreSourceDefault;
}
[_query getDocumentsWithSource:source completion:^(FIRQuerySnapshot * _Nullable snapshot, NSError * _Nullable error) {
if (error) {
[RNFirebaseFirestore promiseRejectException:reject error:error];
} else {

View File

@ -19,7 +19,7 @@
- (id)initWithPath:(RCTEventEmitter *)emitter appDisplayName:(NSString *)appDisplayName path:(NSString *)path;
- (void)delete:(RCTPromiseResolveBlock) resolve rejecter:(RCTPromiseRejectBlock) reject;
- (void)get:(RCTPromiseResolveBlock) resolve rejecter:(RCTPromiseRejectBlock) reject;
- (void)get:(NSDictionary *)getOptions resolver:(RCTPromiseResolveBlock) resolve rejecter:(RCTPromiseRejectBlock) reject;
+ (void)offSnapshot:(NSString *)listenerId;
- (void)onSnapshot:(NSString *)listenerId docListenOptions:(NSDictionary *) docListenOptions;
- (void)set:(NSDictionary *)data options:(NSDictionary *)options resolver:(RCTPromiseResolveBlock) resolve rejecter:(RCTPromiseRejectBlock) reject;

View File

@ -30,9 +30,22 @@ static NSMutableDictionary *_listeners;
}];
}
- (void)get:(RCTPromiseResolveBlock) resolve
- (void)get:(NSDictionary *) getOptions
resolver:(RCTPromiseResolveBlock) resolve
rejecter:(RCTPromiseRejectBlock) reject {
[_ref getDocumentWithCompletion:^(FIRDocumentSnapshot * _Nullable snapshot, NSError * _Nullable error) {
FIRFirestoreSource source;
if (getOptions && getOptions[@"source"]) {
if ([getOptions[@"source"] isEqualToString:@"server"]) {
source = FIRFirestoreSourceServer;
} else if ([getOptions[@"source"] isEqualToString:@"cache"]) {
source = FIRFirestoreSourceCache;
} else {
source = FIRFirestoreSourceDefault;
}
} else {
source = FIRFirestoreSourceDefault;
}
[_ref getDocumentWithSource:source completion:^(FIRDocumentSnapshot * _Nullable snapshot, NSError * _Nullable error) {
if (error) {
[RNFirebaseFirestore promiseRejectException:reject error:error];
} else {

18
lib/index.d.ts vendored
View File

@ -1837,7 +1837,7 @@ declare module 'react-native-firebase' {
endAt(...varargs: any[]): Query;
endBefore(snapshot: DocumentSnapshot): Query;
endBefore(...varargs: any[]): Query;
get(): Promise<QuerySnapshot>;
get(options?: Types.GetOptions): Promise<QuerySnapshot>;
limit(limit: number): Query;
onSnapshot(
onNext: Query.ObserverOnNext,
@ -1882,7 +1882,7 @@ declare module 'react-native-firebase' {
readonly path: string;
collection(collectionPath: string): CollectionReference;
delete(): Promise<void>;
get(): Promise<DocumentSnapshot>;
get(options?: Types.GetOptions): Promise<DocumentSnapshot>;
onSnapshot(
onNext: DocumentReference.ObserverOnNext,
onError?: DocumentReference.ObserverOnError
@ -1897,7 +1897,7 @@ declare module 'react-native-firebase' {
metadataChanges: MetadataChanges,
observer: DocumentReference.Observer
): () => void;
set(data: object, writeOptions?: Types.WriteOptions): Promise<void>;
set(data: object, writeOptions?: Types.SetOptions): Promise<void>;
update(obj: object): Promise<void>;
update(key1: Types.UpdateKey, val1: any): Promise<void>;
update(
@ -2000,7 +2000,7 @@ declare module 'react-native-firebase' {
endAt(...varargs: any[]): Query;
endBefore(snapshot: DocumentSnapshot): Query;
endBefore(...varargs: any[]): Query;
get(): Promise<QuerySnapshot>;
get(options?: Types.GetOptions): Promise<QuerySnapshot>;
limit(limit: number): Query;
onSnapshot(
onNext: Query.ObserverOnNext,
@ -2096,7 +2096,7 @@ declare module 'react-native-firebase' {
set(
documentRef: DocumentReference,
data: Object,
options?: Types.WriteOptions
options?: Types.SetOptions
): Transaction;
// multiple overrides for update() to allow strong-typed var_args
update(docRef: DocumentReference, obj: object): WriteBatch;
@ -2153,7 +2153,7 @@ declare module 'react-native-firebase' {
set(
docRef: DocumentReference,
data: object,
options?: Types.WriteOptions
options?: Types.SetOptions
): WriteBatch;
// multiple overrides for update() to allow strong-typed var_args
update(docRef: DocumentReference, obj: object): WriteBatch;
@ -2247,7 +2247,11 @@ declare module 'react-native-firebase' {
/** The key in update() function for DocumentReference and WriteBatch. */
type UpdateKey = string | FieldPath;
interface WriteOptions {
interface GetOptions {
source: 'default' | 'server' | 'cache';
}
interface SetOptions {
merge?: boolean;
}
}

View File

@ -7,7 +7,12 @@ import Query from './Query';
import { firestoreAutoId } from '../../utils';
import type Firestore from './';
import type { MetadataChanges, QueryDirection, QueryOperator } from './types';
import type {
GetOptions,
MetadataChanges,
QueryDirection,
QueryOperator,
} from './types';
import type FieldPath from './FieldPath';
import type Path from './Path';
import type { Observer, ObserverOnError, ObserverOnNext } from './Query';
@ -67,8 +72,8 @@ export default class CollectionReference {
return this._query.endBefore(snapshotOrVarArgs);
}
get(): Promise<QuerySnapshot> {
return this._query.get();
get(options?: GetOptions): Promise<QuerySnapshot> {
return this._query.get(options);
}
limit(limit: number): Query {

View File

@ -13,6 +13,7 @@ import { getNativeModule } from '../../utils/native';
import type Firestore from './';
import type {
GetOptions,
MetadataChanges,
NativeDocumentSnapshot,
SetOptions,
@ -70,9 +71,29 @@ export default class DocumentReference {
return getNativeModule(this._firestore).documentDelete(this.path);
}
get(): Promise<DocumentSnapshot> {
get(options?: GetOptions): Promise<DocumentSnapshot> {
if (options) {
if (!isObject(options)) {
return Promise.reject(
new Error(
'DocumentReference.get failed: First argument must be an object.'
)
);
} else if (
options.source &&
(options.source !== 'default' &&
options.source !== 'server' &&
options.source !== 'cache')
) {
return Promise.reject(
new Error(
'DocumentReference.get failed: GetOptions.source must be one of `default`, `server` or `cache`.'
)
);
}
}
return getNativeModule(this._firestore)
.documentGet(this.path)
.documentGet(this.path, options)
.then(result => new DocumentSnapshot(this._firestore, result));
}

View File

@ -137,13 +137,32 @@ export default class Query {
);
}
get(): Promise<QuerySnapshot> {
get(options?: GetOptions): Promise<QuerySnapshot> {
if (options) {
if (!isObject(options)) {
return Promise.reject(
new Error('Query.get failed: First argument must be an object.')
);
} else if (
options.source &&
(options.source !== 'default' &&
options.source !== 'server' &&
options.source !== 'cache')
) {
return Promise.reject(
new Error(
'Query.get failed: GetOptions.source must be one of `default`, `server` or `cache`.'
)
);
}
}
return getNativeModule(this._firestore)
.collectionGet(
this._referencePath.relativeName,
this._fieldFilters,
this._fieldOrders,
this._queryOptions
this._queryOptions,
options
)
.then(nativeData => new QuerySnapshot(this._firestore, this, nativeData));
}

View File

@ -10,6 +10,10 @@ export type QueryDirection = 'DESC' | 'desc' | 'ASC' | 'asc';
export type QueryOperator = '<' | '<=' | '=' | '==' | '>' | '>=';
export type GetOptions = {
source: 'default' | 'server' | 'cache',
};
export type SetOptions = {
merge?: boolean,
};

View File

@ -79,18 +79,18 @@ dependencies {
}
// RNFirebase required dependencies
implementation "com.google.firebase:firebase-core:16.0.0"
implementation "com.google.firebase:firebase-core:16.0.1"
implementation "com.google.android.gms:play-services-base:15.0.1"
// RNFirebase optional dependencies
implementation "com.google.firebase:firebase-ads:15.0.1"
implementation "com.google.firebase:firebase-auth:16.0.1"
implementation "com.google.firebase:firebase-auth:16.0.2"
implementation "com.google.firebase:firebase-config:16.0.0"
implementation "com.google.firebase:firebase-crash:16.0.0"
implementation "com.google.firebase:firebase-crash:16.0.1"
implementation "com.google.firebase:firebase-database:16.0.1"
implementation "com.google.firebase:firebase-firestore:17.0.1"
implementation "com.google.firebase:firebase-firestore:17.0.2"
implementation "com.google.firebase:firebase-functions:16.0.1"
implementation "com.google.firebase:firebase-invites:16.0.0"
implementation "com.google.firebase:firebase-invites:16.0.1"
implementation "com.google.firebase:firebase-storage:16.0.1"
implementation "com.google.firebase:firebase-messaging:17.0.0"
implementation "com.google.firebase:firebase-perf:16.0.0"

View File

@ -2,8 +2,8 @@
buildscript {
repositories {
jcenter()
google()
jcenter()
maven {
url 'https://maven.fabric.io/public'
}
@ -18,13 +18,13 @@ buildscript {
allprojects {
repositories {
mavenLocal()
google()
jcenter()
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url "$rootDir/../node_modules/react-native/android"
}
mavenLocal()
google()
}
}

View File

@ -1,65 +1,65 @@
PODS:
- boost-for-react-native (1.63.0)
- BoringSSL (10.0.2):
- BoringSSL/Implementation (= 10.0.2)
- BoringSSL/Interface (= 10.0.2)
- BoringSSL/Implementation (10.0.2):
- BoringSSL/Interface (= 10.0.2)
- BoringSSL/Interface (10.0.2)
- Crashlytics (3.10.1):
- Fabric (~> 1.7.5)
- BoringSSL (10.0.5):
- BoringSSL/Implementation (= 10.0.5)
- BoringSSL/Interface (= 10.0.5)
- BoringSSL/Implementation (10.0.5):
- BoringSSL/Interface (= 10.0.5)
- BoringSSL/Interface (10.0.5)
- Crashlytics (3.10.2):
- Fabric (~> 1.7.7)
- DoubleConversion (1.1.5)
- Fabric (1.7.6)
- Firebase/AdMob (5.0.1):
- Fabric (1.7.7)
- Firebase/AdMob (5.3.0):
- Firebase/Core
- Google-Mobile-Ads-SDK (= 7.30.0)
- Firebase/Auth (5.0.1):
- Google-Mobile-Ads-SDK (= 7.31.0)
- Firebase/Auth (5.3.0):
- Firebase/CoreOnly
- FirebaseAuth (= 5.0.0)
- Firebase/Core (5.0.1):
- FirebaseAuth (= 5.0.1)
- Firebase/Core (5.3.0):
- Firebase/CoreOnly
- FirebaseAnalytics (= 5.0.0)
- Firebase/CoreOnly (5.0.1):
- FirebaseCore (= 5.0.1)
- Firebase/Crash (5.0.1):
- FirebaseAnalytics (= 5.0.1)
- Firebase/CoreOnly (5.3.0):
- FirebaseCore (= 5.0.4)
- Firebase/Crash (5.3.0):
- Firebase/Core
- FirebaseCrash (= 3.0.0)
- Firebase/Database (5.0.1):
- Firebase/Database (5.3.0):
- Firebase/CoreOnly
- FirebaseDatabase (= 5.0.0)
- Firebase/DynamicLinks (5.0.1):
- FirebaseDatabase (= 5.0.1)
- Firebase/DynamicLinks (5.3.0):
- Firebase/Core
- FirebaseDynamicLinks (= 3.0.0)
- Firebase/Firestore (5.0.1):
- FirebaseDynamicLinks (= 3.0.1)
- Firebase/Firestore (5.3.0):
- Firebase/CoreOnly
- FirebaseFirestore (= 0.12.1)
- Firebase/Invites (5.0.1):
- FirebaseFirestore (= 0.12.4)
- Firebase/Invites (5.3.0):
- Firebase/Core
- FirebaseInvites (= 3.0.0)
- Firebase/Messaging (5.0.1):
- Firebase/Messaging (5.3.0):
- Firebase/CoreOnly
- FirebaseMessaging (= 3.0.0)
- Firebase/Performance (5.0.1):
- FirebaseMessaging (= 3.0.2)
- Firebase/Performance (5.3.0):
- Firebase/Core
- FirebasePerformance (= 2.0.0)
- Firebase/RemoteConfig (5.0.1):
- FirebasePerformance (= 2.0.1)
- Firebase/RemoteConfig (5.3.0):
- Firebase/Core
- FirebaseRemoteConfig (= 3.0.0)
- Firebase/Storage (5.0.1):
- Firebase/Storage (5.3.0):
- Firebase/CoreOnly
- FirebaseStorage (= 3.0.0)
- FirebaseABTesting (2.0.0):
- FirebaseCore (~> 5.0)
- Protobuf (~> 3.5)
- FirebaseAnalytics (5.0.0):
- FirebaseAnalytics (5.0.1):
- FirebaseCore (~> 5.0)
- FirebaseInstanceID (~> 3.0)
- GoogleToolboxForMac/NSData+zlib (~> 2.1)
- nanopb (~> 0.3)
- FirebaseAuth (5.0.0):
- FirebaseAuth (5.0.1):
- FirebaseCore (~> 5.0)
- GTMSessionFetcher/Core (~> 1.1)
- FirebaseCore (5.0.1):
- FirebaseCore (5.0.4):
- GoogleToolboxForMac/NSData+zlib (~> 2.1)
- FirebaseCrash (3.0.0):
- FirebaseAnalytics (~> 5.0)
@ -67,23 +67,23 @@ PODS:
- GoogleToolboxForMac/Logger (~> 2.1)
- GoogleToolboxForMac/NSData+zlib (~> 2.1)
- Protobuf (~> 3.5)
- FirebaseDatabase (5.0.0):
- FirebaseDatabase (5.0.1):
- FirebaseCore (~> 5.0)
- leveldb-library (~> 1.18)
- FirebaseDynamicLinks (3.0.0):
- FirebaseDynamicLinks (3.0.1):
- FirebaseAnalytics (~> 5.0)
- FirebaseFirestore (0.12.1):
- FirebaseFirestore (0.12.4):
- FirebaseCore (~> 5.0)
- FirebaseFirestore/abseil-cpp (= 0.12.1)
- FirebaseFirestore/abseil-cpp (= 0.12.4)
- gRPC-ProtoRPC (~> 1.0)
- leveldb-library (~> 1.18)
- Protobuf (~> 3.1)
- FirebaseFirestore/abseil-cpp (0.12.1):
- FirebaseFirestore/abseil-cpp (0.12.4):
- FirebaseCore (~> 5.0)
- gRPC-ProtoRPC (~> 1.0)
- leveldb-library (~> 1.18)
- Protobuf (~> 3.1)
- FirebaseInstanceID (3.0.0):
- FirebaseInstanceID (3.1.1):
- FirebaseCore (~> 5.0)
- FirebaseInvites (3.0.0):
- FirebaseAnalytics (~> 5.0)
@ -99,14 +99,14 @@ PODS:
- GTMSessionFetcher/Core (~> 1.1)
- GTMSessionFetcher/Full (~> 1.1)
- Protobuf (~> 3.5)
- FirebaseMessaging (3.0.0):
- FirebaseMessaging (3.0.2):
- FirebaseCore (~> 5.0)
- FirebaseInstanceID (~> 3.0)
- GoogleToolboxForMac/Logger (~> 2.1)
- Protobuf (~> 3.1)
- FirebasePerformance (2.0.0):
- FirebasePerformance (2.0.1):
- FirebaseAnalytics (~> 5.0)
- FirebaseInstanceID (~> 3.0)
- FirebaseInstanceID (~> 3.1)
- FirebaseSwizzlingUtilities/ISASwizzling (~> 2.0)
- FirebaseSwizzlingUtilities/MethodSwizzling (~> 2.0)
- GoogleToolboxForMac/Logger (~> 2.1)
@ -131,7 +131,7 @@ PODS:
- DoubleConversion
- glog
- glog (0.3.4)
- Google-Mobile-Ads-SDK (7.30.0)
- Google-Mobile-Ads-SDK (7.31.0)
- GoogleAPIClientForREST (1.3.4):
- GoogleAPIClientForREST/Core (= 1.3.4)
- GTMSessionFetcher (>= 1.1.7)
@ -163,25 +163,25 @@ PODS:
- GoogleToolboxForMac/Defines (= 2.1.4)
- GoogleToolboxForMac/NSDictionary+URLArguments (= 2.1.4)
- GoogleToolboxForMac/NSString+URLArguments (= 2.1.4)
- gRPC (1.11.0):
- gRPC-RxLibrary (= 1.11.0)
- gRPC/Main (= 1.11.0)
- gRPC-Core (1.11.0):
- gRPC-Core/Implementation (= 1.11.0)
- gRPC-Core/Interface (= 1.11.0)
- gRPC-Core/Implementation (1.11.0):
- gRPC (1.12.0):
- gRPC-RxLibrary (= 1.12.0)
- gRPC/Main (= 1.12.0)
- gRPC-Core (1.12.0):
- gRPC-Core/Implementation (= 1.12.0)
- gRPC-Core/Interface (= 1.12.0)
- gRPC-Core/Implementation (1.12.0):
- BoringSSL (~> 10.0)
- gRPC-Core/Interface (= 1.11.0)
- gRPC-Core/Interface (= 1.12.0)
- nanopb (~> 0.3)
- gRPC-Core/Interface (1.11.0)
- gRPC-ProtoRPC (1.11.0):
- gRPC (= 1.11.0)
- gRPC-RxLibrary (= 1.11.0)
- gRPC-Core/Interface (1.12.0)
- gRPC-ProtoRPC (1.12.0):
- gRPC (= 1.12.0)
- gRPC-RxLibrary (= 1.12.0)
- Protobuf (~> 3.0)
- gRPC-RxLibrary (1.11.0)
- gRPC/Main (1.11.0):
- gRPC-Core (= 1.11.0)
- gRPC-RxLibrary (= 1.11.0)
- gRPC-RxLibrary (1.12.0)
- gRPC/Main (1.12.0):
- gRPC-Core (= 1.12.0)
- gRPC-RxLibrary (= 1.12.0)
- GTMOAuth2 (1.1.6):
- GTMSessionFetcher (~> 1.1)
- GTMSessionFetcher (1.1.15):
@ -195,7 +195,7 @@ PODS:
- nanopb/encode (= 0.3.8)
- nanopb/decode (0.3.8)
- nanopb/encode (0.3.8)
- Protobuf (3.5.0)
- Protobuf (3.6.0)
- React (0.54.4):
- React/Core (= 0.54.4)
- React/Core (0.54.4):
@ -263,41 +263,41 @@ EXTERNAL SOURCES:
SPEC CHECKSUMS:
boost-for-react-native: 39c7adb57c4e60d6c5479dd8623128eb5b3f0f2c
BoringSSL: 60dd24df4af296bf41d78e5841dbb95d75f88c0d
Crashlytics: aee1a064cbbf99b32efa3f056a5f458d846bc8ff
BoringSSL: cf3f1793eb6e3c445c4d150456341f149c268a35
Crashlytics: 0360624eea1c978a743feddb2fb1ef8b37fb7a0d
DoubleConversion: e22e0762848812a87afd67ffda3998d9ef29170c
Fabric: f8d42c893bb187326a7968b62abe55c36a987a46
Firebase: d6861c2059d8c32d1e6dd8932e22ada346d90a3a
Fabric: bda89e242bce1b7b8ab264248cf3407774ce0095
Firebase: 68afeeb05461db02d7c9e3215cda28068670f4aa
FirebaseABTesting: 1f50b8d50f5e3469eea54e7463a7b7fe221d1f5e
FirebaseAnalytics: 19812b49fa5f283dd6b23edf8a14b5d477029ab8
FirebaseAuth: acbeef02fe7c3a26624e309849f3fe30c84115af
FirebaseCore: cafc814b2d84fc8733f09e653041cc2165332ad7
FirebaseAnalytics: b3628aea54c50464c32c393fb2ea032566e7ecc2
FirebaseAuth: 463b8ce33bd5d05f706dcd4615499e3212b4132b
FirebaseCore: 62f1b792a49bb9e8b4073f24606d2c93ffc352f0
FirebaseCrash: 8900571fd763fd5bdda04522ec53da979456e3ce
FirebaseDatabase: 697eb53e5b4fe7cd4fa8756c1f82a9fca011345f
FirebaseDynamicLinks: c70e8ef2f267f13459db89b8816b13a06b2278d2
FirebaseFirestore: f686b8e83f3cf8bbc37db6e98e01029a14f01f55
FirebaseInstanceID: 83e0040351565df711a5db3d8ebe5ea21aca998a
FirebaseDatabase: 482bad9c2abd422bb2321194fb8c937e67426a89
FirebaseDynamicLinks: d624a7adc81a8fd70d52be5a6a47a2bc0644b923
FirebaseFirestore: 53f6fe858494c39dbfd5237655e0641152a88c89
FirebaseInstanceID: f3f0657372592ecdfdfe2cac604a5a75758376a6
FirebaseInvites: d7534f94d0610b892bac8ee0cf4218a14be46c28
FirebaseMessaging: f2360a966ecfb0d14facf0fbdf306efc2df0ddbe
FirebasePerformance: 1ec6c40e5dad2543ca4c4f25d15168bde6322c2c
FirebaseMessaging: 6894b8fe0a0cf26c3b13dad729f1131654ae0bdb
FirebasePerformance: 1ebd87ffee5ca814582db1dc9e25651792ba02db
FirebaseRemoteConfig: 3c57e4644bd6976b671ae0b725cd709f198bd1f5
FirebaseStorage: 7ca4bb7b58a25fa647b04f524033fc7cb7eb272b
FirebaseSwizzlingUtilities: 6c22677c50d0b6f5f0dc637c1233f13694a3003f
Folly: 211775e49d8da0ca658aebc8eab89d642935755c
glog: 1de0bb937dccdc981596d3b5825ebfb765017ded
Google-Mobile-Ads-SDK: 7404f68120ae8682afeb5af001fbf4aad731c78e
Google-Mobile-Ads-SDK: 6e529e748b45507a2ca904e0b5a52669ba3920c4
GoogleAPIClientForREST: f7951c455df271bc6259b3ddb4073d0026475ccf
GoogleSignIn: d9ef55b10f0aa401a5de2747f59b725e4b9732ac
GoogleToolboxForMac: 91c824d21e85b31c2aae9bb011c5027c9b4e738f
gRPC: 70703dc9ba31c72341fc7f37745cc1c379edee96
gRPC-Core: 164639cd8ae18ca8b65477fafb2efbaecf4f181a
gRPC-ProtoRPC: bb5fddf3424aa4fad74d76736578a79fe40e244e
gRPC-RxLibrary: 26d53d1b1f306befd4ad4e15bd6de27839a82481
gRPC: 9362451032695e2dfb7bafcd3740e3a27939e4ff
gRPC-Core: 9696b220565b283e021cf2722d473a4a74b7622a
gRPC-ProtoRPC: a1bd56fb1991a8dae4581250d7259eddabb66779
gRPC-RxLibrary: 1ed5314e8b38cd6e55c9bfa048387136ae925ce9
GTMOAuth2: c77fe325e4acd453837e72d91e3b5f13116857b2
GTMSessionFetcher: 5fa5b80fd20e439ef5f545fb2cb3ca6c6714caa2
leveldb-library: 08cba283675b7ed2d99629a4bc5fd052cd2bb6a5
nanopb: 5601e6bca2dbf1ed831b519092ec110f66982ca3
Protobuf: 8a9838fba8dae3389230e1b7f8c104aa32389c03
Protobuf: 0fc0ad8bec688b2a3017a139953e01374fedbd5f
React: c237e42de9c70e5cac6eeb52b4cfd3a0910c1f00
RNFirebase: 2b25fd2e60269f26bb0a76c71dcc942b35a77df0
yoga: 55da126afc384965b96bff46652464373b330add

4768
tests/package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -93,6 +93,26 @@ function documentReferenceTests({
snapshot.id.should.equal('doc1');
snapshot.metadata.should.be.an.Object();
});
it('should support GetOptions source=`default`', async () => {
const snapshot = await firebase.native
.firestore()
.doc('document-tests/doc1')
.get({ source: 'default' });
snapshot.id.should.equal('doc1');
snapshot.metadata.should.be.an.Object();
should.equal(snapshot.metadata.fromCache, false);
});
it('should support GetOptions source=`cache`', async () => {
const snapshot = await firebase.native
.firestore()
.doc('document-tests/doc1')
.get({ source: 'cache' });
snapshot.id.should.equal('doc1');
snapshot.metadata.should.be.an.Object();
should.equal(snapshot.metadata.fromCache, true);
});
});
context('onSnapshot()', () => {