samuelgozi/firebase-firestore-lite

Support for CollectionGroup?

Closed this issue · 8 comments

Would be nice to query CollectionGroup:

`
// Reference to a collection group
const groupCollection = db.group('group');

const items = await groupCollection.list(); // Returns an instance of List
`

I second this! Thanks for this AMAZING project

This feature exists, I just don’t remember how to use it.
I need to check that.

Ok, so as I stated before it is practically possible, but It's not intuitive at all.
Im working on a small refactor that will make it more intuitive. There should be no breaking changes.
I'll update when it's ready.

I'm still working on it. The hard part is to find an API that makes sense. But because of how the Firebase team implemented this "behind the scenes" it is harder than you might think.
Im now doing some testing to make sure nothing was broken because of the changes. I'll update soon.

I wish I could help man, but I really appreciate your hard work! Steve

It took me some time but im finally done. Sorry about that, job got in the way..
You will find this feature in version 1.0.1.
There are multiple ways of creating a collection group, but the easiest one is:

db.collectionGroup('name of the collection');

This requrns a Query class which you can use to filter the results.
This method can also receive an options object as the second argument(same as with ref.query).
In the options argument there is an optional property called parent. It should be a Reference to a document, and when passed, the collection group will only include collections that are nested within that document (I think this feature is not present in the official SDK).
By default the collection groups will include all collections in the database with that name.

Please let me know if there are any issues, or if you find this API cumbersome.

@samuelgozi Thank you!!
Next week i will include this version on a project.

Please let me know how it goes!