sequelize/sequelize — pull request #904 by hdanak (2013-09-14 20:49:18+00:00)
Title: Refactor data-types to use a common makeType factory function.

This patch cleans up the data-type definitions to use a common `makeType` function. There should be no functional change.

The original motivation for this change was to make the type functions be able to sort of "bud" more specific variants of themselves. I thought it would be a good idea to start a dialog with a reasonably minor change before going off on a tangent. The basic change I'm proposing (beyond this minor cleanup) is to use a more formal prototypical inheritance to extend types. Here's an example use case:

```javascript
var Project = sequelize.define('Project', {
title: Sequelize.STRING.bud({ allowNull: false, unique: true })
description: Sequelize.TEXT
})
```

A more useful application of this would be to define specialty types (maybe with validators, like a URL or Email type) that can be later extended further, and use them more than once in models. For instance:

```javascript
var URL = Sequelize.STRING.bud({ validate: { isUrl: true }});

var Image = sequelize.define('Image', {
url: URL.bud({ allowNull: false, unique: true })
...
})
```

Another option is to have two kinds of type classes, basic and compound, where basic types would map one-to-one to db types, and compound types would be as described above. Even just a better defined interface to the basic types would be helpful for someone (me) to create an external extension that does this. I'd appreciate any commentary on this.

Just to be clear, the particular change in this patch is only to clean up how data types are defined.