Coder Social home page Coder Social logo

firestore-join's People

Contributors

anti-h3r0 avatar diegofhe avatar josepeha avatar jpcapdevila avatar

Stargazers

 avatar

Watchers

 avatar  avatar

firestore-join's Issues

Improve date parser for nested dates

Is your feature request related to a problem? Please describe.
Firestore stores dates as their own timestamp type. To use dates on our application and with third party libraries we need to convert them to JS dates.

We have a transform function that checks for timestamps at the first level of data and if the value has the .toDate function defined, we call it and store that value instead.

The problem is that now we are storing dates on nested properties, either on objects or arrays of objects. Our transform function is not picking this cases.

Describe the solution you'd like
Modify the transform function:

function transformDates(serializedDocument: any) {

Refactor the code so we can recursively transform the data inside serializedDocument.

Add cache layer to includes

Is your feature request related to a problem? Please describe.
When we use firebase join to include reference relations, we do this on an inefficient way.

Example:

We get all the news for the homepage, and for each new piece we include the categories.

This means that if we get 50 news, we hit the db to get the categories. Even tho we only have 10 categories.

Same thing happens on the category's articles page, we hit the db to get same category N (number of articles) times.

This problem will repeat across the app because most of the relations we have are belongs to.

Describe the solution you'd like
Create a cache layer that we can manage from the application to set cached collections.

I imagine a function exported from 'firestore-join' with this signature:

setCachedCollection('apps/community/articleCategories', serializedDocumentArray);

serializedDocumentArray could come from a snapshot listener, or from a simple .get() that was serialized.

Then I would store a map for the cache with {'collectionName1': array1, 'collectionName2: array2, ... }

if we wanted to clear the cache we could just do:

setCachedCollection('apps/community/articleCategories',[]);

Then from inside firestore-join we need to modify the parts of the code that usedocumentReference.get() (line 99 and 111) a reference to check on the cache first based on the documentReference.collection and documentReference.path .

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.