GithubHelp home page GithubHelp logo

supposedlysam / firefuel Goto Github PK

View Code? Open in Web Editor NEW
8.0 8.0 1.0 11.35 MB

A Firebase Cloud Firestore architecture to jump-start your project

License: MIT License

Dart 76.78% Kotlin 0.18% Ruby 1.24% Swift 0.65% Objective-C 0.02% CMake 7.30% C++ 11.41% C 0.66% HTML 1.78%

firefuel's People

Contributors

mrgnhnt96 avatar supposedlysam avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

sam-parks-ogk

firefuel's Issues

Create a query method

I wonder if there is a way to simplify the query?

Currently you have to reference the collectionRef, add the where, limit, etc, and then .get() to retrieve the docs.

Any of the query methods would be kind of hard to use too, most of them require a DocumentSnapshot, which we aren't providing.

Create whereDocId method

Required Changes

  • Create whereDocId on Collection
  • Create a Clause.byDocId named constructor
  • Create a OrderBy.docId named constructor

feat: Create A FirefuelObserver

It would be nice to have the ability to create a logger so we know what database calls are being made. These would output to the debug console in VSCode and would work similar to the BlocObserver

Support Logical OR Queries

Firestore doesn't support OR queries but has a workaround we can implement

... In this case, you should create a separate query for each OR condition and merge the query results in your app.

Let's have a discussion around what we could do to support this.

feat!: Split create method into create and createById

Change

Split the create method on the FirefuelCollection into create and createById methods.

Reason

Sometimes I forget to pass in the DocumentId when creating a Document and an id gets auto-generated for me

Benefits

  • Semantic usage
  • No optional values to forget / not know is there

feat: add limit ability

When working with Firestore, sometimes you want to be able to limit the amount of data you get back at once.

I believe most use cases will be to limit after doing some sort of filter, so we should create an optional named argument limit on the where clause.

In the case of subcollections, you might not need to do any kind of filtering, so we should also have a top-level limit method

Question: offline support?

Hey guys,

Awesome plugin, I only stumbled on it and tried recently but I think it's a brilliant tool on top of Firestore that can do much of the heavy-lifting in a smooth and coherent manner, great job!

I wanted to check if you plan on supporting offline usage (to the extent Firestore does)?

At the moment, when you're offline and try creating a new document or updating an existing (and cached) one will hang because of the consistent await usage.
E.g. the create function in firefuel_collection.dart will hang on line 29 and the createById on line 39 etc.

Annoyingly enough the official docs do not suggest a best practice; at least I haven't found something like that yet.
One could omit the awaits altogether (most of the official examples do I think) or roll promises. I don't think there's a third option, is there? Here's a good summary for reference.

Either way, just wanted check with you.

Cheers

docs: update readme for firefuel

Before submitting to pub.dev we need to update our readme to link to the documentation and provide some basics around how to use the package

Rename `collectionRef` and `collectionPath`

I think that we should rename collectionRef and collectionPath to just ref and path.

When the collection gets created the variable name will most likely contain collection

final TestCollection testCollection = TestCollection();

// feels a bit redundant
testCollection.collectionRef;
testCollection.collectionPath;

// quicker and easier
testCollection.ref;
testCollection.collectionPath;

Create a way to access `orderBy`

You can access the order by with the dot annotation .orderBy(field, asc/desc), but there is not a way to do that with firefuel yet.

docs: add example of subcollections on Collection and Repository

We've had some verbal discussions about how to set up a subcollection.

One option is to have the top level Collection contain the properties of the other subcollections

Example

class MyTopLevelCollection extends FirefuelCollection {
  ...
  final Collection mySubcollection1;
  final Collection mySubcollection2;
  final Collection mySubcollection3;
}

class MySubcollection1 extends ...
class MySubcollection2 extends ...
class MySubcollection3 extends ...

Then, in the Repository (if you decide to use one)

class MyTopLevelRepository extends FirefuelRepository {
  ...
  final Repository mySubrepository1;
  final Repository mySubrepository2;
  final Repository mySubrepository3;
}

class MySubrepository1 extends ...
class MySubrepository2 extends ...
class MySubrepository3 extends ...

where each repository would handle any exceptions.

Breaking them out this way would allow the user to exclusively use Repositories or Collections without having to use both and the separation of concerns will still be in the correct classes.

batch: Creating & replacing

If a createById and replace transaction are in the same batch, the replace will silently fail.

Because batches perform all transactions at the same time, replace has nothing to replace because the document technically has not been created.

This test fails

    test('should overwrite all values in document', () async {
      final newUser = TestUser('newUser');
      final updatedUser = TestUser('updatedUser');

      await testBatch.createById(value: newUser, docId: originalDocId);

      await testBatch.replace(
        value: updatedUser,
        docId: originalDocId,
      );

      await testBatch.commit();

      final readUser = await testCollection.read(originalDocId);

      expect(updatedUser, readUser);
    });

How do we wanna handle this? Do we want to perform some sort of check? or just let it fail?

Support isNotEqualTo for Sequences

In Firestore, using isNotEqualTo on a number (and I'm assuming a date because it's also a sequence) is not supported.

The workaround suggested is to create two queries and combine the results.

... however you can get the same result set by combining two queries, one with the clause where("age", isLessThan: 30) and one with the clause where("age", isGreaterThan: 30)

We should make this work as expected for anyone using the isNotEqualTo Where clause

Proposal: export firebase package to reduce required imports

Suggested Change

  1. Include firebase_core in dependencies for firefuel
  2. Export firebase_core and cloud_firestore from firefuel
  3. Update docs/readme with directions on how to override versions of the above deps if needed

Pros

  • Easier to use firefuel
  • Less dependencies the user needs to manage

Cons

  • Users will need to know to import firefuel rather than firebase_core or cloud_firestore
  • There may be more confusion about where the responsibilities of the firefuel package start and end
    • This could lead to a lot of redirecting to the other packages when issues come our way
  • We will have to be careful to never overlap any names from the above packages

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.