Skip to content

Many to many relation isn't really many to many? #645

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
runia1 opened this issue Aug 21, 2018 · 2 comments
Closed

Many to many relation isn't really many to many? #645

runia1 opened this issue Aug 21, 2018 · 2 comments

Comments

@runia1
Copy link

runia1 commented Aug 21, 2018

In the docs it says:

For example, a User may have many Posts that she might like. In this case, you can store the set of Posts that a User likes using relation. In order to add a Post to the “likes” list of the User, you can do:


var user = Parse.User.current();
var relation = user.relation("likes");
relation.add(post);
user.save();

My use case is actually this exact setup. We have users and they can "like" 0-many posts, so I set it up exactly as stated above. My issue now is that for a given Post or set of Posts, I need to query how many users have liked each Post. I'm having trouble figuring out how to query for that... Can someone help me out? I'm not sure if this is a limitation or if I just don't know enough to figure this out. I've thought about storing a counter on the Post itself and using increment() and decrement() each time a User likes or unlikes a Post, but I'd rather not if I can get away with it.

@flovilmart
Copy link
Contributor

Thanks for your question!

We want to make sure to keep signal strong in the GitHub issue tracker – to make sure that it remains the best place to track issues that affect the development of Parse Server.

Questions like yours deserve a purpose-built Q&A forum. Would you like to post this question to Stack Overflow with the tag #parse.com? We'll be happy to answer there. Post a link to your Stack Overflow question here, so that we don't lose track of it.

You may also use Server Fault for questions about managing your own servers.

@runia1
Copy link
Author

runia1 commented Aug 21, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants