I am working in the Relational Persistence project that supports writing A12 documents to tables of a relational database (instead of storing JSONs). We parse the JSONs of Document models and Relationship models to create and maintain the needed database tables. Therefore we need to fully understand how the JSONs are serialized.
I created a simple Relationship model with SME (version 12.2.4) that models a n:1 relationship between “users” and “groups” (see picture below).
I set Orderable on the users role (since this is the many side and the users should be orderable by the user), but after saving this model in SME, I see that in the JSON file the “ordered: true” is set on the groups role (see picture below).
Is this by intention that the “ordered: true” is set on the other role in model JSON?
Or did I any mistake with modelling in SME?
Hi @patrick-warm-bloom
This is correctly modeled. You can also see a working example of this is the e-commerce workspace that comes with the installer.
In this workspace, the Relationship Model BundleProduct initially has both roles set to Orderable = yes. This means that in the Preview App, we can reorder the Products in the Product Bundle and this order is preserved when refreshing and re-loading.
As you can see in the Tool-tip in the Simple Model Editor:
If the child role of a relationship that is used in a tree model is set to Orderable, the order of siblings of the same parent can be changed via drag & drop.
This means that we actually only need to set the child role to be orderable. We can adapt the model and test the settings.
Test 1 - incorrect setting
- Role: Bundle
- Orderable: yes
- Role: Product
- Orderable: no
→ I cannot reorder the Products in a Bundle in the Product Bundle Tree.
Test 2- correct setting
- Role: Bundle
- Orderable: no
- Role: Product
- Orderable: yes
→ I can reorder the Products in a Bundle in the Product Bundle Tree.
I can’t make any statement on how or why the Modeling Settings are saved in the json model.
Hi @malcolm-silver-ice,
thanks for the quick reply and the hint with the e-commerce workspace. I tested it on my end and also could verify that only Product role needs to be “Orderable” to be able to re-order the products.
I assume that the SME creates the JSON correctly, so the “ordered: true” is set on the other role in the JSON. But to be 100% sure, it would be great if someone could make any statement that the “ordered” flag is set on the other role by intention. Could you ask someone or tell me who could know this?
Thanks,
Patrick
Hi @mgm-plenger, I’ve created a linked thread in the Relationship Engine category.