I have an action-only rule sheet to seed some data for later rule sheets. I have a Product entity which has an N:1 association to a ProductGroup entity.
To add Product records, I have lines similar to this:
Product.new[productId='P1', name='Lettuce'] Product.new[productId='P2', name='Filet Mignon'] Product.new[productId='P3', name='Apple']
To add ProductGroup records, I have:
ProductGroup.new[productGroupId='PG1', 'Produce'] ProductGroup.new[productGroupId='PG2', 'Meat']
So what is the syntax to associate the "Lettuce" product to the "Produce" product group?
We’ll consider three cases:
You use the += notation for one-to-many associations
With a vocab like this
And a rule sheet like this
You will get this:
If the product groups already exist then you might use something like this to add the products by using aliases to the product collections within the product groups:
newUnique can be used to avoid creating duplicate items
Download PDF version.