Parse - Using relations versus pointers?

前端 未结 4 549
生来不讨喜
生来不讨喜 2020-12-28 09:49

I am using Parse as my backend. I have problems setting up the correct relation between objects.

I basically have a class named Post, each post belongs to a user(PFU

4条回答
  •  一整个雨季
    2020-12-28 10:44

    A Relation is for when you want a long list of related classes, where an array doesn't work, or when you want to query the related objects as needed and not have the list included every time you load the containing object.

    Basically you have 4 options with Parse:

    • Pointer - single reference to another class (1 to 0..1)
    • Array - collection of pointers, loaded with the object every time (1 to 0..n, small lists)
    • Relation - collection of pointers, like a join table in SQL (handled under the covers for you), you must run a query against it to load values (1 to 0..n)
    • Custom join class - really just another object (like many-to-many join in SQL) with a Pointer to each side plus any related information (1..n to 1..n)

    In your case a simple Pointer would do what you want.

提交回复
热议问题