Skip to content

param being a list of an entity #4

Answered by fuelen
LostKobrakai asked this question in Q&A
Discussion options

You must be logged in to vote

In general, I avoid inserting a list of something by default, as the more data in the DB - the slower tests are. But let's look at a couple of approaches.

  • Standard and recommended way: use separate commands to create blog and to create posts:
# schema
command :create_blog do
  resolve(...)
  produce :blog
end
command :create_post do
  param :blog, entity: :blog
  resolve(...)
  produce :post
end

# usage
ctx
|> produce(:blog)
|> produce(post: :post1)
|> produce(post: :post2)
  • Use generate option which generates a list of params. This should work fine if you can generate all data points with faker/etc and other entities (associations) are not required. However, even if posts require othe…

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by fuelen
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #3 on August 02, 2024 07:11.