lib/common/model.js
function () {
            var self = this;
            var indexes = self.$indexes || [];

            return Promise.try (function() {
                assert.arrayOfObject(indexes, '$indexes should be an array of object');

                //validate and assign default arguments before creating indexes
                //if necessary, convert the indexes format to fit for different database
                _.forEach(indexes, function(indexItem) {
                    assert.object(indexItem.keys, 'Database index keys should be object');
                    if (indexItem.options) {
                        assert.object(indexItem.options, 'Database index options should be object');
                    }
                    else {
                        indexItem.options = {};
                    }
                });

                return indexes;
            })
            .then(function(indexes) {
                if (_.isEmpty(indexes)) {
                    return;
                }
                switch(self.connection.toString()) {
                    case 'mongo':
                        return Promise.map(indexes, function(indexItem) {
                            return self.createMongoIndexes([indexItem.keys, indexItem.options]);
                        });
                    default:
                        break;
                }
            });
        }
function () {
            var self = this;
            var indexes = self.$indexes || [];

            return Promise.try (function() {
                assert.arrayOfObject(indexes, '$indexes should be an array of object');

                //validate and assign default arguments before creating indexes
                //if necessary, convert the indexes format to fit for different database
                _.forEach(indexes, function(indexItem) {
                    assert.object(indexItem.keys, 'Database index keys should be object');
                    if (indexItem.options) {
                        assert.object(indexItem.options, 'Database index options should be object');
                    }
                    else {
                        indexItem.options = {};
                    }
                });

                return indexes;
            })
            .then(function(indexes) {
                if (_.isEmpty(indexes)) {
                    return;
                }
                switch(self.connection.toString()) {
                    case 'mongo':
                        return Promise.map(indexes, function(indexItem) {
                            return self.createMongoIndexes([indexItem.keys, indexItem.options]);
                        });
                    default:
                        break;
                }
            });
        }
function ( ) { var self = this ; var indexes = self . $indexes || [ ] ; return Promise . try ( function ( ) { assert . arrayOfObject ( indexes , '$indexes should be an array of object' ) ; //validate and assign default arguments before creating indexes //if necessary, convert the indexes format to fit for different database _ . forEach ( indexes , function ( indexItem ) { assert . object ( indexItem . keys , 'Database index keys should be object' ) ; if ( indexItem . options ) { assert . object ( indexItem . options , 'Database index options should be object' ) ; } else { indexItem . options = { } ; } } ) ; return indexes ; } ) . then ( function ( indexes ) { if ( _ . isEmpty ( indexes ) ) { return ; } switch ( self . connection . toString ( ) ) { case 'mongo' : return Promise . map ( indexes , function ( indexItem ) { return self . createMongoIndexes ( [ indexItem . keys , indexItem . options ] ) ; } ) ; default : break ; } } ) ; }
Create indexes for different database

the waterline has bug for index creation and it also doesn't support compound index,
this function is to manually create indexes regardless what waterline will do. This
function support both single-field and compound index

@return {Promise} Resolved if create indexes successfully.
Create indexes for different database