Creating a relation between User.current() data and a Class

Hi Parse Community,

New member here! I am building with NEXTjs w/ TypeScript — I want to be able to leverage the relational database query method so that a User.current() (current user) would be able to track actions they do.

Think like a to-do list…so:

  • each user would be able to track the status of their own To-Dos, and when they are checked-off, it would update their own ToDos in the to-do list class.
  • when a user wants to see their completed to-dos, it will query their OWN to-do’s, not the entire Class

I believe this is a relation but is it a pointer? I am curious how to create relationships between a current user’s data and a data field.

Any clarity on this would be awesome!!
Best,
Brian

Pointer is used for one-to-many relationship while Relation is used for many-to-many. If each user has multiple todos and each todo belongs to a single user, it is a one-to-many that you need. So I’d go with a Pointer field in the Todo Class pointing out to the User class. In the case that a single Todo can be associated to multiple user, you need to go with relation or create your own joint class.

1 Like

Thanks @davimacedo ! Is this close to what you think it would look like? What I’m struggling to understand is what is a Pointer and what is a Relation given the association of each user to their respective objects (Todos).

I created a diagram to illustrate what I’m thinking of with 3 goals:

  • Goal: Bob or Sarah can query their OWN “list of Todos”
  • Goal: Each Todo is ownable by ONLY one user
  • Goal: Each user can create many ToDos

Could you help me understand more of what is the relation and what is the pointer?

I’d only create the Pointer in the Todo class and not the Relation in the User class. You can do all queries you need only using the Pointer.