• Resolved brunomac

    (@brunomac)


    Hi Jim, any resource online on how to use the WHERE clause?
    Imagine I have an object (pod), called cat, it has a name and gender, mother, father and descendents.

    I have 3 fields as relationships, mother, father, and descendents.

    • mother is a simple relationship to the same cat pod, but WHERE gender = female
    • father is a simple relationship to the same cat pod, but WHERE gender = male
    • descendents is a multiple relationship to the same cat pod, but WHERE not in mother and father ids, (bi-direccional relationship to cat, linked to the father and mother fields.)

    I was able to achieve half the requirements by adding on the where clause this:
    gender.meta_value = ‘f’and for the father, gender.meta_value = ‘m’

    In the form list, I would like to remove the entries of the item i’m editing from the father/mother list.

    ex. If I’m editing the cat pod named “garfield” and since he’s male, how can I remove it from the father list? how can I remove it from the descendents list?

Viewing 1 replies (of 1 total)
  • Plugin Contributor Jim True

    (@jimtrue)

    Yes, our primary reference is the Find documentation on our website along with the video on that page: https://pods.io/docs/pods/find/

    It actually sounds like you’re trying to filter the Customized WHERE clauses for your relationships. That’s a little bit of a different animal. If the primary gender.meta_value is working for you, that’s awesome, but if you want to exclude the current post from those lists, it’s a little more complicated

    Since these are circular relationships (ie they’re all back to the same post type), you could try adding:

    AND id NOT IN ('{@ID}')

    The problem you might run into, however, is this will give a SQL error when the post hasn’t been created yet, because ID for the current post doesn’t exist yet.

    This is also something we’ll be able to address after Pods 2.8 as many items like this are conditional.

Viewing 1 replies (of 1 total)
  • The topic ‘Relationship Where clauses’ is closed to new replies.