Skip to content

Commit

Permalink
feat: start support for collection ids
Browse files Browse the repository at this point in the history
  • Loading branch information
alextekartik committed Aug 21, 2023
1 parent 0c4aa9f commit d2d5654
Show file tree
Hide file tree
Showing 10 changed files with 32 additions and 8 deletions.
4 changes: 4 additions & 0 deletions firestore/lib/firestore.dart
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ abstract class FirestoreService {

/// True if it supports listing collections.
bool get supportsListCollectionIds;

Firestore firestore(App app);
}

Expand Down Expand Up @@ -85,6 +86,9 @@ abstract class Firestore {
/// Retrieves multiple documents from Firestore.
Future<List<DocumentSnapshot>> getAll(List<DocumentReference> refs);

/// If supported list all root collections
Future<List<CollectionReference>> listCollections();

/// Service access
FirestoreService get service;
}
Expand Down
4 changes: 3 additions & 1 deletion firestore/lib/src/firestore_logger.dart
Original file line number Diff line number Diff line change
Expand Up @@ -711,7 +711,9 @@ class TransactionLogger with TransactionMixin implements Transaction {
}
}

class FirestoreLogger with FirestoreMixin implements Firestore {
class FirestoreLogger
with FirestoreDefaultMixin, FirestoreMixin
implements Firestore {
final FirestoreLoggerOptions options;
final Firestore firestore;

Expand Down
6 changes: 6 additions & 0 deletions firestore/lib/utils/firestore_mixin.dart
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,12 @@ bool firestoreTimestampsInSnapshots(Firestore firestore) {
return true;
}

mixin FirestoreDefaultMixin implements Firestore {
@override
Future<List<CollectionReference>> listCollections() {
throw UnimplementedError();
}
}
mixin FirestoreMixin implements Firestore {
FirestoreSettings? firestoreSettings;

Expand Down
2 changes: 1 addition & 1 deletion firestore/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: tekartik_firebase_firestore
description: Firebase firestore core
version: 1.0.0
version: 1.1.0
publish_to: none

environment:
Expand Down
2 changes: 1 addition & 1 deletion firestore/test/common/mixin_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class FirestoreServiceMock with FirestoreServiceDefaultMixin {
}
}

class FirestoreMock with FirestoreMixin {
class FirestoreMock with FirestoreDefaultMixin, FirestoreMixin {
@override
WriteBatch batch() {
throw UnimplementedError();
Expand Down
4 changes: 3 additions & 1 deletion firestore_browser/lib/src/firestore_browser_impl.dart
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,9 @@ FirestoreServiceBrowser? _firebaseFirestoreServiceBrowser;
FirestoreService get firestoreService =>
_firebaseFirestoreServiceBrowser ??= FirestoreServiceBrowser();

class FirestoreBrowser with FirestoreMixin implements Firestore {
class FirestoreBrowser
with FirestoreDefaultMixin, FirestoreMixin
implements Firestore {
@override
final FirestoreServiceBrowser service;
final native.Firestore nativeInstance;
Expand Down
6 changes: 5 additions & 1 deletion firestore_idb/lib/src/firestore_idb.dart
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,11 @@ FirestoreService getFirestoreService(idb.IdbFactory idbFactory) =>
FirestoreServiceIdb(idbFactory);

class FirestoreIdb extends Object
with FirestoreMixin, FirestoreSubscriptionMixin, FirestoreDocumentsMixin
with
FirestoreDefaultMixin,
FirestoreMixin,
FirestoreSubscriptionMixin,
FirestoreDocumentsMixin
implements Firestore {
final AppLocal appLocal;
final FirestoreServiceIdb firestoreServiceIdb;
Expand Down
2 changes: 1 addition & 1 deletion firestore_rest/lib/src/firestore_rest_impl.dart
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ Value toRestValue(FirestoreRestImpl firestore, dynamic value) {
}

class FirestoreRestImpl
with FirestoreMixin
with FirestoreDefaultMixin, FirestoreMixin
implements Firestore, FirestoreDocumentContext {
@override
final FirestoreServiceRestImpl service;
Expand Down
6 changes: 5 additions & 1 deletion firestore_sembast/lib/src/firestore_sembast.dart
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,11 @@ class WriteResultSembast extends WriteResultBase {
}

class FirestoreSembast extends Object
with FirestoreMixin, FirestoreSubscriptionMixin, FirestoreDocumentsMixin
with
FirestoreDefaultMixin,
FirestoreMixin,
FirestoreSubscriptionMixin,
FirestoreDocumentsMixin
implements Firestore {
var dbLock = Lock();
Database? db;
Expand Down
4 changes: 3 additions & 1 deletion firestore_sim/lib/src/firestore_sim_client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,9 @@ class CollectionReferenceSim extends Object
}
}

class FirestoreSim extends Object with FirestoreMixin implements Firestore {
class FirestoreSim extends Object
with FirestoreDefaultMixin, FirestoreMixin
implements Firestore {
FirestoreSim(this.firestoreServiceSim, this.appSim);

final FirestoreServiceSim firestoreServiceSim;
Expand Down

0 comments on commit d2d5654

Please sign in to comment.