python-mock-firestore
python-mock-firestore copied to clipboard
Add support for collection_group query
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()))
For those who are looking for collection_group, check this repository: https://github.com/ainbr/python-mock-firestore