@@ -261,39 +261,39 @@ extend(BaseCollection.prototype, {
261261 } ) ;
262262 return promise ;
263263 } ,
264- createHashIndex ( fields , unique , cb ) {
265- if ( typeof unique === 'function' ) {
266- cb = unique ;
267- unique = undefined ;
264+ createHashIndex ( fields , opts , cb ) {
265+ if ( typeof opts === 'function' ) {
266+ cb = opts ;
267+ opts = undefined ;
268268 }
269269 if ( typeof fields === 'string' ) {
270270 fields = [ fields ] ;
271271 }
272+ if ( typeof opts === 'boolean' ) {
273+ opts = { unique : opts } ;
274+ }
272275 var { promise, callback} = this . _connection . promisify ( cb ) ;
273- this . _api . post ( 'index' , {
274- type : 'hash' ,
275- fields : fields ,
276- unique : Boolean ( unique )
277- } , { collection : this . name } , function ( err , res ) {
276+ opts = extend ( { unique : false } , opts , { type : 'hash' , fields : fields } ) ;
277+ this . _api . post ( 'index' , opts , { collection : this . name } , function ( err , res ) {
278278 if ( err ) callback ( err ) ;
279279 else callback ( null , res . body ) ;
280280 } ) ;
281281 return promise ;
282282 } ,
283- createSkipList ( fields , unique , cb ) {
284- if ( typeof unique === 'function' ) {
285- cb = unique ;
286- unique = undefined ;
283+ createSkipList ( fields , opts , cb ) {
284+ if ( typeof opts === 'function' ) {
285+ cb = opts ;
286+ opts = undefined ;
287287 }
288288 if ( typeof fields === 'string' ) {
289289 fields = [ fields ] ;
290290 }
291+ if ( typeof opts === 'boolean' ) {
292+ opts = { unique : opts } ;
293+ }
291294 var { promise, callback} = this . _connection . promisify ( cb ) ;
292- this . _api . post ( 'index' , {
293- type : 'skiplist' ,
294- fields : fields ,
295- unique : Boolean ( unique )
296- } , { collection : this . name } , function ( err , res ) {
295+ opts = extend ( { unique : false } , opts , { type : 'skiplist' , fields : fields } ) ;
296+ this . _api . post ( 'index' , opts , { collection : this . name } , function ( err , res ) {
297297 if ( err ) callback ( err ) ;
298298 else callback ( null , res . body ) ;
299299 } ) ;
0 commit comments