sdepold/sequelize — pull request #323 by janmeier (2012-11-13 15:31:03+00:00)
Title: Performance improvements v2 - Refactor DAO to use prototype

##### Changes
This refactor includes the following changes:
* Each DAOFactory now has its own ```this.DAO``` function, that returns a customized DAO for each factory - this means that instead of modifying the instance each time a DAO is created, the DAOFactory modifies its DAO prototype. This has made the DAO.build step considerably faster, meaning faster select queries.
* Mixin injects getters and settings on the prototype
* Default values are injected on the prototype
* Validators are injected on the prototype

##### Performance measurements
Running 1700 mixed queries (both find and findAll - using a sample set of queries taken from our site) goes from 170ms to 30ms.

This has made a small change the default values, meaning that some values that were previously null are now undefined, and vice versa. This is a side-effect of not looping through all attributes each time DAOFactory.create is called, but only looping through the attributes that actually have default values. Tests have been refactored accordingly.