Giter VIP home page Giter VIP logo

Comments (8)

chaoming avatar chaoming commented on August 11, 2024 1

The adminRefs and userRefs are for reading the user documents under the users collection.

from saas.

jeffreydavis83 avatar jeffreydavis83 commented on August 11, 2024

Makes sense. Thanks!

from saas.

jeffreydavis83 avatar jeffreydavis83 commented on August 11, 2024

Sorry I am gonna ask another noob question,

What if we don’t use the adminRefs and userRefs and instead fetch from the database using id only? I am just curious how adminRefs and userRefs are benefiting us?

from saas.

chaoming avatar chaoming commented on August 11, 2024

No worries.

There are two approaches to not use adminRefs and userRefs.

  1. After reading the user IDs from access or admins array, loop through the users collection one by one based on the list of IDs. I think this is definitely not a very efficient way to retrieve data because each ID will need an API call to the users collection to retrieve the user document.

  2. After reading the user IDs from access or admins array, execute a query to retrieve all the user documents from the users collection that match the IDs in the array. However, I can't find examples to query a collection based on a list of IDs in the document https://firebase.google.com/docs/firestore/query-data/queries, so I designed the system to use array of reference to resolve it. This is possible based on googleapis/nodejs-firestore#990, but I am not sure about the performance compared to the current method.

Cheers,

from saas.

jeffreydavis83 avatar jeffreydavis83 commented on August 11, 2024

Thanks man! I just have this one doubt,

The cloud function getAccountUsers includes:

 let getUsers = [];
            accountRef.data().accessRefs.forEach(user => {
                getUsers.push(getDoc('users/'+user.id));
            });
            return Promise.all(getUsers);

Aren’t you executing getDoc for each user? Wouldn’t each user then will require an API call in this case?

from saas.

chaoming avatar chaoming commented on August 11, 2024

True, looks like it's OK to remove adminRefs and accessRefs and simply to use admins and access to simplify the data structure. Thanks for the question.

from saas.

chaoming avatar chaoming commented on August 11, 2024

This issue is resolved in commit dd1286c

from saas.

jeffreydavis83 avatar jeffreydavis83 commented on August 11, 2024

Thanks!

from saas.

Related Issues (20)

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.