python-mock-firestore icon indicating copy to clipboard operation
python-mock-firestore copied to clipboard

Add support for collection_group query

Open juviwhale opened this issue 5 years ago • 1 comments

Add support for the new collection_group query that was recently added.

# Example Data
parent_1 = db.collection(u'parents').document(u'molly_smith').set({
        u'name': u'Molly Smith',
        u'age': 49
})
child_1a = db.collection(u'parents').document(u'u'molly_smith').collection(u'children').document().set({
        u'name': u'Tom Smith JR',
        u'age': 17
})
parent_2 = db.collection(u'parents').document(bill_jones').set({
        u'name': u'Bill Jones',
        u'age': 56
})
child_2a = db.collection(u'parents').document(u'bill_jones').collection(u'children').document().set({
        u'name': u'Jerry Jones',
        u'age': 17
})

# Collection Group Query
children = db.collection_group(u'children').where(u'age', u'==',17')
docs = children.stream()
for doc in docs:
    print(u'{} => {}'.format(doc.id, doc.to_dict()))

Documentation of Query

GoogleCloudPlatform Example Snippet

juviwhale avatar Nov 12 '19 04:11 juviwhale

For those who are looking for collection_group, check this repository: https://github.com/ainbr/python-mock-firestore

flrngel avatar Nov 21 '22 19:11 flrngel