gameboy86 / matchbox-orm

ORM package for google Cloud Firestore.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

(Feature) Support sub-collections

fernandovalera opened this issue · comments

Currently, collection names are static and root level. I want to make a get query on a sub-collection of a model.

Querying could look something like this:

class A(models.Model):
    a_field_1 = models.TextField()

class B(models.Model):
    b_field_1 = models.TextField()
    b_field_2 = models.TextField()

a = A.objects.get(a_field_1='value1')
b = B.objects.get(parent_model=a, b_field_1='value1', b_field_2='value2')

Internally, the full collection name for 'a' and its own unique id would be appended to the beginning of the collection name for 'b' of class B. Something like this:

full collection name for 'a': a
full collection name for 'b': a/<unique_id_for_a>/b

This format could be used for any depth of sub-collections

Hi,
I published version 0.2.4 with support for subcollection. Documentation you find in README. Please let me know if everything is ok