relating two card types
Suppose your Wagn site has Person cards and Company cards. You have a Person named George who works for a Company named Banana Computers, and you'd like to relate George and Banana Computers in such a way that each shows up on the other card.
The typical solution is a pointer-search relationship. It can look something like this:
- On each Person card there is a pointer card named +employer
- George+employer is edited to point to Banana Computers
- On each Company card there is a search card named +employees
- Banana Computers+employees will find George!
The WQL for Banana Computers+employees will look something like this:
{"type":"Person","right_plus":["employer",{"refer_to":"Banana Computers"}]}In English, this means "find all the cards whose type is Person that have a +employer card that points to Banana Computers.
Of course, you wouldn't want to have to write this WQL over and over again for every single Company card, so the common practice is to make the +employees searches into virtual cards. To do this, you could go to Banana Computers+employees and then click on advanced and create a structure rule that applies to "all +employees cards on Company cards". (This will create a card called "Company+employees+*type plus right+*structure"). The WQL for that card will look something like this:
{"type":"Person","right_plus":["employer",{"refer_to":"_self"}]}
--
You received this message because you are subscribed to the Google Groups "Wagneers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to wagneers+u...@googlegroups.com.
To post to this group, send email to wagn...@googlegroups.com.
Visit this group at http://groups.google.com/group/wagneers.
For more options, visit https://groups.google.com/groups/opt_out.
Hi Brett,To answer your question I started a (long overdue) feature card called "relating cards". The howto section attempts to explain the solution as follows:
{"type":"Person","right_plus":["employer",{"refer_to":"_self"}]}
"right_plus": [ "employer", { "refer_to": "_self"} ]
"right_plus": [ { "name": "employer" }, { "refer_to": "_self"} ]
--
You received this message because you are subscribed to the Google Groups "Wagneers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to wagneers+u...@googlegroups.com.
To post to this group, send email to wagn...@googlegroups.com.
Visit this group at http://groups.google.com/group/wagneers.
For more options, visit https://groups.google.com/groups/opt_out.
WQL is also unlike SQL in that it uses an object notation (which can be expressed in JSON, ruby, or other formats). The rationale there is that this notation will be much easier to manipulate in various ways, such as via a GUI. We've wanted for years to create a WQL gui and haven't yet, but WQL itself is very coder friendly, so I hope we'll get to tackle that soon.
Among WQL queries, the most unusual thing about "right_plus" is that it requires an array (with hard brackets: []).You may have noticed that every time you see a Hash / named list in WQL, it represents a card definition which itself can be used as a self-standing WQL query. This is actually great for debugging. You can, for example, try the query {"refer_to":"_self"} on its own to see whether you're getting the response you expect. It's often very useful to build your searches inside out in this way.
This gets us back to the issue of why this is all so unconventional looking. A few key points:
- The name "right_plus" flows from compound names, which themselves. It can be taken to mean "cards where +(def1) = (def2)".
- The two card definitions are unusual because in most systems, the field itself is hard-coded, not part of the data itself. If you were to write SQL, it might look something like "select * from persons where employer_id = 1234". Employer_id is part of the data structure, NOT the data. In Wagn, "employer" is just another card. Cards are structured by more cards, so WQL must help you navigate both the cards that are structured and the cards that do the structuring.
missing word(s) around "themselves"?
- The name "right_plus" flows from compound names, which themselves. It can be taken to mean "cards where +(def1) = (def2)".
--
You received this message because you are subscribed to the Google Groups "Wagneers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to wagneers+u...@googlegroups.com.
To post to this group, send email to wagn...@googlegroups.com.
Visit this group at http://groups.google.com/group/wagneers.
For more options, visit https://groups.google.com/groups/opt_out.
For what it's worth, I'm actually contemplating a proposal to rename the "right_plus", and "left_plus" relationships. (We'd either migrate old queries or support the old syntax, but we wouldn't just break existing queries).Would it be more intuitive if "right_plus" were "field" and "left_plus" were "field_of"? eg:"field":["employee",{"refer_to":"Banana Computers"}]would mean "cards with a +employee field that refers to Banana Computers" (returns George)Meanwhile, this:"field_of":["George",{"refer_to":"Banana Computers"}]...would return "employee".