@@ -415,7 +415,7 @@ export class PostgresStorageAdapter {
415
415
return toParseSchema ( schema )
416
416
} )
417
417
. catch ( ( err ) => {
418
- if ( err . code === PostgresUniqueIndexViolationError && err . detail . indexOf ( className ) >= 0 ) {
418
+ if ( err . code === PostgresUniqueIndexViolationError && err . detail . includes ( className ) ) {
419
419
throw new Parse . Error ( Parse . Error . INVALID_CLASS_NAME , `Class ${ className } already exists.` )
420
420
}
421
421
throw err ;
@@ -445,7 +445,7 @@ export class PostgresStorageAdapter {
445
445
relations . push ( fieldName )
446
446
return ;
447
447
}
448
- if ( [ '_rperm' , '_wperm' ] . indexOf ( fieldName ) >= 0 ) {
448
+ if ( [ '_rperm' , '_wperm' ] . includes ( fieldName ) ) {
449
449
parseType . contents = { type : 'String' } ;
450
450
}
451
451
valuesArray . push ( fieldName ) ;
@@ -678,7 +678,7 @@ export class PostgresStorageAdapter {
678
678
valuesArray . push ( object [ fieldName ] . objectId ) ;
679
679
break ;
680
680
case 'Array' :
681
- if ( [ '_rperm' , '_wperm' ] . indexOf ( fieldName ) >= 0 ) {
681
+ if ( [ '_rperm' , '_wperm' ] . includes ( fieldName ) ) {
682
682
valuesArray . push ( object [ fieldName ] ) ;
683
683
} else {
684
684
valuesArray . push ( JSON . stringify ( object [ fieldName ] ) ) ;
@@ -707,7 +707,7 @@ export class PostgresStorageAdapter {
707
707
let initialValues = valuesArray . map ( ( val , index ) => {
708
708
let termination = '' ;
709
709
let fieldName = columnsArray [ index ] ;
710
- if ( [ '_rperm' , '_wperm' ] . indexOf ( fieldName ) >= 0 ) {
710
+ if ( [ '_rperm' , '_wperm' ] . includes ( fieldName ) ) {
711
711
termination = '::text[]' ;
712
712
} else if ( schema . fields [ fieldName ] && schema . fields [ fieldName ] . type === 'Array' ) {
713
713
termination = '::jsonb' ;
@@ -1031,9 +1031,9 @@ export class PostgresStorageAdapter {
1031
1031
const qs = `ALTER TABLE $1:name ADD CONSTRAINT $2:name UNIQUE (${ constraintPatterns . join ( ',' ) } )` ;
1032
1032
return this . _client . none ( qs , [ className , constraintName , ...fieldNames ] )
1033
1033
. catch ( error => {
1034
- if ( error . code === PostgresDuplicateRelationError && error . message . indexOf ( constraintName ) >= 0 ) {
1034
+ if ( error . code === PostgresDuplicateRelationError && error . message . includes ( constraintName ) ) {
1035
1035
// Index already exists. Ignore error.
1036
- } else if ( error . code === PostgresUniqueIndexViolationError && error . message . indexOf ( constraintName ) >= 0 ) {
1036
+ } else if ( error . code === PostgresUniqueIndexViolationError && error . message . includes ( constraintName ) ) {
1037
1037
// Cast the error into the proper parse error
1038
1038
throw new Parse . Error ( Parse . Error . DUPLICATE_VALUE , 'A duplicate value for a field with unique values was provided' ) ;
1039
1039
} else {
0 commit comments