hukusuke1007 / flamingo

[Flutter Library] Flamingo is a firebase firestore model framework library. 🐤
https://pub.dev/packages/flamingo
MIT License
118 stars 20 forks source link

Clarity on Root Usage #7

Closed Purus closed 4 years ago

Purus commented 4 years ago

This is actually related to https://github.com/hukusuke1007/flamingo/issues/1.

But since it is close already I am creating new one here.

final root = firestore.collection('version').document('1');

My questions may be dumb, but I am trying to understand the reason behind this. I am sure you have a good reason for this.

  1. By saying root, does it refer to the root document for a given firestore collection?
  2. Why we have to provide a document value? In my case my document's uid is dynamic.
  3. What if I have multiple collections? like users, files, etc.
  4. Does this change for every project?
hukusuke1007 commented 4 years ago

Thank you for comment.

At that time, I was thinking it want to manage version. But if it update version, there are many changes cost and risk. Therefore, I modified developer can be set root reference.(It entrust that setting root reference).

https://github.com/hukusuke1007/flamingo/blob/master/lib/flamingo.dart#L27


Recently my projects, I’m setting the following code.

/// Not set reference.
Flamingo.configure();

I answer your questions.

By saying root, does it refer to the root document for a given firestore collection? -> Yes.

Why we have to provide a document value? In my case my document's uid is dynamic. -> I wanted to manage static value.

What if I have multiple collections? like users, files, etc. -> Can be set custom collection name if developer set collection in override method.

CollectionReference get collectionRootReference => rootReference.collection('users');
CollectionReference get collectionRootReference => rootReference.collection('files');


Example (This collection is “public”. “publics” is also ok.) https://github.com/hukusuke1007/flamingo/blob/master/example/lib/model/public/public.dart#L11

Does this change for every project? -> Yes. It depends on every project.

I'm sorry for my poor English. Best regards.