Skip to content
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

Customize name of related entity ID #12

Open
XedinUnknown opened this issue Oct 5, 2018 · 0 comments
Open

Customize name of related entity ID #12

XedinUnknown opened this issue Oct 5, 2018 · 0 comments

Comments

@XedinUnknown
Copy link

XedinUnknown commented Oct 5, 2018

When retrieving related entities with WP_Query->query() by ID or set of IDs, the resulting entities will have the ID of the related entities set as the mb_origin property. This allows us to avoid having to query backwards for each entity. However, when returning the results, such as in a function e.g. get_answers_for_questions(), the consumer of such a function cannot know whether the entities were retrieved by mb-relationships, or in some other way, and therefore cannot rely on some generic mb_origin property.

It could be useful to be able to set a name for it. In my case, when I try to get Answer posts related to questions with the specified IDs, it would be useful if the Question ID of each Answer was under e.g. question_id. This could be as easy as changing the column alias name.

Also, if multiple Answers match each question ID, there will be more than one Answer in the result - each with a different mb_origin. It could be extremely useful to have the ability to have only unique Answers, but their e.g. question_ids parameter set to an array of IDs of related Questions.

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

1 participant