0
votes

I have some problems with relations in Parse, I don't know why I can't do a relation fine.

my app: a user can create posts, and look posts from other users, a user can add a favorite post to a list, and then see the list of their favorites. I think I need relations many to many for do it.

I have a button "add favorite" , a class "favorites" and a class "posts"

favorites has userId(current user) , and post(favorite post) posts has namepost,description,category

I tried this.

ParseObject fav =  ParseObject.create("favorites");
                        fav.put("userid",ParseUser.getCurrentUser());
                        ParseRelation relation = posts.getRelation("objectId");
                        fav.put("post",relation);
                        fav.saveInBackground();

But never saves . I also I tried to create a column in Parse "User" class but never works. Some suggestions?. Thanks.

1

1 Answers

0
votes

Ok for answer my own question. I created a class Favorites with two columns, user, post

  • user: ParseUser.getCurrentUser()
  • post : obj.getobjectId

If I want to retrieve the favorites, first I search for them in a query and save it in a list.