-
-
Notifications
You must be signed in to change notification settings - Fork 53
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Supports "createMany" model method #33
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please also add to README (model methods, but also in the Getting started section - I found it hard to get started without any data, getAll() is returning an empty array which is probably fine, but I kind of expected that factory()
would populate some mock data automagically)
Thanks, that's a good point. We need to mention that |
@kettanaito we've recently integrated Creating larger sets of models based on factories is something that we've been looking for - I also saw that prisma supports a similar case with Is this PR still being worked on? I saw some todos left, but there wasn't a lot of activity recently. |
Hey, @tomaszgil. Thank you for your kinds words! I'm excited that MSW and its ecosystem helps you achieve your goals 🎉 I'm not working on this feature currently. That being said, I still find this a crucial API to have, so if you're willing to help me out with this I'd be thankful. I think some of the pre-requisites for I like that Prisma reference! This library is inspired by Prisma a lot, and modeling our const users = db.user.createMany([
{ name: 'Sonali', email: '[email protected]' },
{ name: 'Alex', email: '[email protected]' },
])
|
Hi, I just found this after having noticed a gap in there not being a createMany method, and creating #237 to address it. Feel free to close my PR if this is going to supercede it. Alternatively, if you like the route I've taken and would like me to adjust it to use an array format like Prisma, I'm happy to tweak it so this can get moved along. |
Have updated #237 to reflect the prisma-like syntax. Perhaps your initial approach with this branch could be satisfied in future by a |
GitHub
Changes
createMany
model method to create multiple random instances of the model.oneOf
relational property when listing theoptions.relations
increateMany
(cannot create an entity without all its relational models specified, soboolean
makes no sense).