Coder Social home page Coder Social logo

Comments (6)

rolandjitsu avatar rolandjitsu commented on July 18, 2024

@SonicWolfMan no worries, it's out there to help.

So the reason the chores are per user is because they are private and other users cannot access chores that are not theirs. And it was implemented this way to show how one would implement private stores in Firebase per user using Angular 2.

But I am unsure what you are asking here.

If you want to still have users signing in but you want then to share chores, you would need to implement some kind of grouping and organize data in Firebase in such a manner that you can grab all chores that belong to the group the user is part of instead of the chores that belong to the user.

The above is slightly more complicated to implement. But if you want to have all chores public and you do not care what is user is authenticated, you can remove that user key. And if you do not want any auth, you can remove all the user and auth related logic as well.

from angular-lab.

SonicWolfMan avatar SonicWolfMan commented on July 18, 2024

You are correct. In the end there are 3 possible outcomes.

  • Private (the way your code is setup now)
  • Public (removing the user info)
  • Shared

Originally in my question I was describing the Public option. However, in the end what I'm aiming for is the shared option. As you stated, this is going to be slightly more complicated to implement. In addition I'm planning on adding the concept of each user having multiple todo lists. Thanks again!

from angular-lab.

SonicWolfMan avatar SonicWolfMan commented on July 18, 2024

Another question. I'm trying to create the concept of multiple named todo lists. Essentially trying to create:

  • ChoreGroups
    • MyChores

I'm looking the services.ts file and am wondering how to change it. Setting up ChoreGroups is easy in that it is the same access pattern as Chores is now in your code. However, I'm wondering about retrieving the list of MyChores based upon a selected ChoreGroup. Is it even possible to pass a key as a parameter to services.ts? Does that even make sense? If it is possible, what would that look like?

Thanks

from angular-lab.

rolandjitsu avatar rolandjitsu commented on July 18, 2024

Well, you should look at flattening your data structure a bit, something that I did not do properly in the first place as I was in a rush.

But ideally you would have something like:

{
    groups: {
        test: {
            members: {
                one: true
            }
        }
    },
    users: {
        one: {
            groups: {
                test: true
            }
        }
    },
    chores: {
        <identifier>: {
            user: 'one',
            groups: {
                test: true
            }
        }
    }
}

And then you would filter your chores both by the user and the groups it belongs to. Sorting by the user is pretty easy:

let root = new Firebase('your firebase app link');
let query = root.child('/chores').orderByChild('user').equalTo(userRef.key()) // userRef is the ref to the authenticated user

After this you can listen on the ref and further filter by groups. Or you can directly filter by groups and have your security rules not allow reads on the chores that the user property value is not the same as the user that us currently authenticated.

As you can see, there are many ways of going at this, but I cannot tell you how exactly to change the code as I would have to take the time to do it myself and see what works best.

I hope this helps a bit though.

from angular-lab.

SonicWolfMan avatar SonicWolfMan commented on July 18, 2024

Thanks, that was very helpful!

from angular-lab.

rolandjitsu avatar rolandjitsu commented on July 18, 2024

I'll close this. You can use the gitter channel for further questions.

from angular-lab.

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.