jugglingdb/postgres-adapter — pull request #40 by bmatcuk (2014-03-28 04:46:30+00:00)
Title: Composite indexes

Added support for floating point datatypes, and, more importantly, added support for composite indexes.

The syntax is similar to the MySQL adapter. I've added some documentation to the README, reproduced here:

1. Support for `float` datatypes, ala the mysql adapter. Just add `dataType: 'float'` to your column properties:

```javascript
var Model = schema.define('Model', {
realNumber: {type: Number, dataType: 'float'}
});
```

2. Support for single and multi-column indexes, ala the mysql adapter. Single column indexes are specified by adding `index: true` to the column properties. Unique single-column indexes are created by adding `unique: true` to the column properties (it is unnecessary to also specify `index: true` since it is implied). Multi-column indexes are added by specifying `indexes` in the settings hash of the `schema.define` method. Single-column indexes may also be specified this way if you want to have a little more control over their options. Each key in the `indexes` hash is the name of the index, and the value is a hash which specifies the index properties:

```javascript
var Model = schema.define('Model', {
column1: {type: Number, index: true},
column2: {type: Number}
}, {
indexes: {
indexName1: {
columns: 'column1, column2',
type: 'btree'
}
}
});
```

The full list of supported index properties are:

```javascript
{
columns: 'comma, delimited, list, of, columns',
keys: ['array', 'of', 'columns'], // takes precedence over "columns"!
type: 'TYPE', // 'btree', 'hash', etc
kind: 'KIND' // 'unique' is the only valid option
}
```

See the [postgres documentation](http://www.postgresql.org/docs/9.1/static/sql-createindex.html) for more information about `type` and `kind`.