Skip to content

Feature Request - Add truncate() to repository api #207

Closed

Description

@dcworldwide

Please add the ability to delete all table table via the repository api. Thanks

Activity

  1. pleerock commented on Jan 16, 2017

    @pleerock
    Member

    I was thinking about to add this method already. However there is one small consideration why Im still not sure about this issue. Repository is a most commonly used class with public api needed for regular work with entities. truncate is more specific method and generally not commonly used, and should be used carefully. Is it a good idea to add such method there?

  2. dcworldwide commented on Jan 16, 2017

    @dcworldwide
    ContributorAuthor

    Cool. I think it logically fits within the CRUD functionality of a Repository or the Entity Manager.

    I understand the concern. If it has an explicit name like truncate or removeAll IMO it is pretty clear to me about it's intent. Others might have different opinions...

  3. pleerock commented on Jan 16, 2017

    @pleerock
    Member

    I think we can add this method. But I don't like truncate name. Looks very mysql-specific for more. Maybe we can came up with better name (which also will be correct for mongodb in the future)?

  4. dcworldwide commented on Jan 16, 2017

    @dcworldwide
    ContributorAuthor

    Yeah agree with that. Ideas.... clear(), removeAll()

  5. pleerock commented on Jan 16, 2017

    @pleerock
    Member

    clear sounds better, but is it descriptive enough name?

  6. dcworldwide commented on Jan 16, 2017

    @dcworldwide
    ContributorAuthor

    For me yes, reminds me of clearing a collection or array. Others might think differently

  7. dcworldwide commented on Jan 18, 2017

    @dcworldwide
    ContributorAuthor

    Also, I've recently come up with a similar edge case. Sometimes I need to delete all data by FK. I.e. delete all orders belong to user X. I think the remove() api only allows for the removal of a single record atm. Would be nice to have the orm take care of this too.

  8. pleerock commented on Jan 20, 2017

    @pleerock
    Member

    but thats not safe and can bring lot of issues on production....

  9. pleerock commented on Jan 26, 2017

    @pleerock
    Member

    will be released in @next very soon...

  10. dcworldwide commented on Jan 31, 2017

    @dcworldwide
    ContributorAuthor

    Great, thanks!

  11. added
    good first issue
    and removed on Apr 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    featuregood first issue

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions