firestoreodm-flutter icon indicating copy to clipboard operation
firestoreodm-flutter copied to clipboard

Support collection groups

Open Lyokone opened this issue 8 months ago • 0 comments

  How can I do a collection group query with a sub-collection? It looks like right now I have to have a parent (collectionId) first and then get the sub-collection part of that collection. But I want to be able to query against all sub collection documents.

I have:

@Collection<Configuration>('configurations')
@Collection<SharedWith>('configurations/*/sharedWith')
final configurationRef = ConfigurationCollectionReference();

And I want to be able to query like I would if I had created a group query

final Query<Map<String, dynamic>> _configSharedWith = _firestore.collectionGroup('sharedWith');
// Query across all sub collection documents
final sharedWith = await _configSharedWith.where('userId', isEqualTo: userId).get();

Originally posted by @FXschwartz in https://github.com/firebase/flutterfire/discussions/7475#discussioncomment-3311361

Copied from https://github.com/firebase/flutterfire/issues/9751

Lyokone avatar May 29 '24 14:05 Lyokone