Smart Relationship - reference key

Hello,
I am trying out your smart relationships right now. I managed that somehow, but in general, I am not pretty sure how to deal with reference key.

I found just one sentence about that:

A HasMany Smart Relationship is created like a Smart Field with the reference option to indicates on which collection the Smart Relationship points to.

I can imagine that it is a reference to that related table, but what exactly should be there please?

  • Model name?
  • Table name?
  • Is that necessary for generated url?
  • For what is this indication necessary?
  • In your example, you have reference: 'customers.id', could it be also without id? Could be there customers.name for example, please?

I mean, I can blindly follow that example and put there xy.id every time, I just don’t know exactly what are the implications of that.

Thank you very much clarification.

Best regards,

Vaclav

Hi @Vaclav :wave: The reference options is used to differentiate a “classic” smart field from a “relationship” smart field.
This reference is the collection name of the wanted relationship.
This is not used for generated url but it is used to adapt the UI.
In the case of hasmany relation ship you not necessarily need to write .id the most important thing is the reference collection name.
Let me know if that help :pray:

Hi @Arnaud_Moncel,
thank you for the explanation. I would have one more question please.
What if I want to have a table with three or four tables? E.g.:

  • Customers
  • Orders
  • Products in order

Should I reference just “Orders” or both “Orders and Products” in array or something?

Thank for your help,

Vaclav

If i understand well your question, you want to have four smart relationship linked to your main collection.
So you need to define, in your forest/yourmaincollection.js, four smart relationship fields.
And after that you need to create the four related route like router.get('/yourmaincollection/:yourmaincollection_id/relationships/firstrelationships',....
I dont know if it’s clear, let me know.