Skip to content

Model class should use prototype rather than assigning new methods to each model in the constructor. #773

Description

@insidewhy

Using prototype has a number of advantages, but mostly the current method being used to populate methods per instance is very bad for performance and memory usage.

Activity

  1. insidewhy commented on Mar 4, 2017

    @insidewhy
    Author

    It's the same for other classes too, like AggregateFunctions etc. In fact the only place this code is using prototype is in the drivers. 👎

  2. dxg commented on Apr 7, 2017

    @dxg
    Collaborator

    Probably has something todo with the fact we're using getters and setters.
    Perhaps when this package was originally written JS didn't allow getters/setters on prototypes? Not sure.

    Would be interested to see if it's possible to change it. Feel free to submit some code.

  3. insidewhy commented on Jun 2, 2017

    @insidewhy
    Author

    Even if that were the case it's still a terrible reason for making every non-property instantiated in the constructor. This is some of the worst performing code I've used in ages, it was a massive mistake for my previous client to use it. No one should use orm2.

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

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions