Skip to content
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

Clear all entities #44

Closed
marcosvega91 opened this issue Jan 6, 2021 · 3 comments · Fixed by #45
Closed

Clear all entities #44

marcosvega91 opened this issue Jan 6, 2021 · 3 comments · Fixed by #45

Comments

@marcosvega91
Copy link
Member

I think that for testing purposes we need a way to delete all entities between tests. As an alternative, a user can loop all entities and call the delete method.

@kettanaito
Copy link
Member

kettanaito commented Jan 6, 2021

Agree, there should be an API to drop a mock database.

As much as I would love to see a db.drop() API, I think we should stick to the design where each db method stands for a model name. It's plain and intuitive and we shouldn't put any additional "special" API in there the users wouldn't expect.

Perhaps we can expose a set of utils that operate on a given database instance?

import { factory, drop } from '@mswjs/data'

const db = factory(...)
drop(db)

I was planning to go with a similar approach with the seed utility for seeding a given database (#31).

I'd love to discuss the API and once that's settled either of us can take it to works.

@marcosvega91
Copy link
Member Author

drop utility could be very useful I think, nice :)

@kettanaito
Copy link
Member

I can take this one if you don't mind?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants