What are the Slack Archives?
It’s a history of our time together in the Slack Community! There’s a ton of knowledge in here, so feel free to search through the archives for a possible answer to your question.
Because this space is not active, you won’t be able to create a new post or comment here. If you have a question or want to start a discussion about something, head over to our categories and pick one to post in! You can always refer back to a post from Slack Archives if needed; just copy the link to use it as a reference..
Hey Spryks! Can anyone advise on how we do Joins across modules when pulling data? Example… I’ve
Hey Spryks!
Can anyone advise on how we do Joins across modules when pulling data?
Example…
I’ve set up a module called “Recipes” and also created “RecipeSearch” as module for handling Elastic Search. (I’ve followed the guidance in the Backend Dev Course for this).
Ok so the Recipe table is working and so is elastic search… but each recipe has a list of ingredients. These are on another table with an FK to the recipes table.
What’s best practice for me to pull in this data also? Is there a guide for this?
My approach to this would be to change the RecipeTransfer to reflect the ingredients data, then use the RecipeSearchWriter to pull this data. However, I think I would need to change the RecipeEntity to include the ingredient data … ?
Any help on this would be much appreciated.
Comments
-
If you want to be fully decoupled you can define a RecipeExpanderPluginInterface inside your recipe module and then implement concrete expander plugins in related modules, like IngredientExpanderPlugin. These plugins will handle populating any extra data for the recipe.
0 -
However decoupling comes at the cost of repeated db calls, so if performance is important you should try and compile as much as possible in pub/sync so everything is there ready for your view code.
0 -
Thank you @UKEP86J66… yes the first option is probably fine, since I’m going to be collecting all the data and sending it to Reddis and Elastic Search… so the extra DB calls are only pre-sync…
Is there a good pre-built example of an expander plugin interface that I can use to learn from?
0 -
Luckily there are plenty in Spryker, I was looking at
ViewDataExpanderPluginInterface
this morning which made me think of this pattern.0 -
But there are plenty of other examples in Spryker if you search for
*ExpanderPlugin*
classes. They should, in theory, all follow a similar pattern0 -
You can also decouple any transfer object changes across modules. For example your
IngredientExpander
might want to populate aingredients
property ofRecipeTransfer
so you can add this property by extending the transfer inside theIngredient
module. That way if you ever remove the ingredient module it should tidy up after itself 🙂0
Categories
- All Categories
- 42 Getting Started & Guidelines
- 7 Getting Started in the Community
- 8 Additional Resources
- 7 Community Ideas and Feedback
- 76 Spryker News
- 929 Developer Corner
- 787 Spryker Development
- 89 Spryker Dev Environment
- 362 Spryker Releases
- 3 Oryx frontend framework
- 35 Propel ORM
- 68 Community Projects
- 3 Community Ideation Board
- 30 Hackathon
- 3 PHP Bridge
- 6 Gacela Project
- 26 Job Opportunities
- 3.2K 📜 Slack Archives
- 116 Academy
- 5 Business Users
- 370 Docker
- 551 Slack General
- 2K Help
- 75 Knowledge Sharing
- 6 Random Stuff
- 4 Code Testing
- 32 Product & Business Questions
- 70 Spryker Safari Questions
- 50 Random