diff --git a/spec/ParseConfigKey.spec.js b/spec/ParseConfigKey.spec.js index a171032087..ae31ff954d 100644 --- a/spec/ParseConfigKey.spec.js +++ b/spec/ParseConfigKey.spec.js @@ -81,7 +81,8 @@ describe('Config Keys', () => { connectTimeoutMS: 5000, socketTimeoutMS: 5000, autoSelectFamily: true, - autoSelectFamilyAttemptTimeout: 3000 + autoSelectFamilyAttemptTimeout: 3000, + disableIndexFieldValidation: true }, })).toBeResolved(); expect(loggerErrorSpy.calls.all().reduce((s, call) => s += call.args[0], '')).not.toMatch(invalidKeyErrorMessage); diff --git a/src/Options/Definitions.js b/src/Options/Definitions.js index 6218e484a8..81c4f56cce 100644 --- a/src/Options/Definitions.js +++ b/src/Options/Definitions.js @@ -1092,6 +1092,12 @@ module.exports.DatabaseOptions = { 'The MongoDB driver option to specify the amount of time, in milliseconds, to wait to establish a single TCP socket connection to the server before raising an error. Specifying 0 disables the connection timeout.', action: parsers.numberParser('connectTimeoutMS'), }, + disableIndexFieldValidation: { + env: 'PARSE_SERVER_DATABASE_DISABLE_INDEX_FIELD_VALIDATION', + help: + 'Set to `true` to disable validation of index fields. When disabled, indexes can be created even if the fields do not exist in the schema. This can be useful when creating indexes on fields that will be added later.', + action: parsers.booleanParser, + }, enableSchemaHooks: { env: 'PARSE_SERVER_DATABASE_ENABLE_SCHEMA_HOOKS', help: diff --git a/src/Options/docs.js b/src/Options/docs.js index e3ef19655a..51167b7f9d 100644 --- a/src/Options/docs.js +++ b/src/Options/docs.js @@ -242,6 +242,7 @@ * @property {Boolean} autoSelectFamily The MongoDB driver option to set whether the socket attempts to connect to IPv6 and IPv4 addresses until a connection is established. If available, the driver will select the first IPv6 address. * @property {Number} autoSelectFamilyAttemptTimeout The MongoDB driver option to specify the amount of time in milliseconds to wait for a connection attempt to finish before trying the next address when using the autoSelectFamily option. If set to a positive integer less than 10, the value 10 is used instead. * @property {Number} connectTimeoutMS The MongoDB driver option to specify the amount of time, in milliseconds, to wait to establish a single TCP socket connection to the server before raising an error. Specifying 0 disables the connection timeout. + * @property {Boolean} disableIndexFieldValidation Set to `true` to disable validation of index fields. When disabled, indexes can be created even if the fields do not exist in the schema. This can be useful when creating indexes on fields that will be added later. * @property {Boolean} enableSchemaHooks Enables database real-time hooks to update single schema cache. Set to `true` if using multiple Parse Servers instances connected to the same database. Failing to do so will cause a schema change to not propagate to all instances and re-syncing will only happen when the instances restart. To use this feature with MongoDB, a replica set cluster with [change stream](https://docs.mongodb.com/manual/changeStreams/#availability) support is required. * @property {Number} maxPoolSize The MongoDB driver option to set the maximum number of opened, cached, ready-to-use database connections maintained by the driver. * @property {Number} maxStalenessSeconds The MongoDB driver option to set the maximum replication lag for reads from secondary nodes. diff --git a/src/Options/index.js b/src/Options/index.js index 29ac1628f7..355d0d2888 100644 --- a/src/Options/index.js +++ b/src/Options/index.js @@ -343,7 +343,7 @@ export interface ParseServerOptions { :DEFAULT: [] */ rateLimit: ?(RateLimitOptions[]); /* Options to customize the request context using inversion of control/dependency injection.*/ - requestContextMiddleware: ?((req: any, res: any, next: any) => void); + requestContextMiddleware: ?(req: any, res: any, next: any) => void; } export interface RateLimitOptions { @@ -629,6 +629,8 @@ export interface DatabaseOptions { autoSelectFamily: ?boolean; /* The MongoDB driver option to specify the amount of time in milliseconds to wait for a connection attempt to finish before trying the next address when using the autoSelectFamily option. If set to a positive integer less than 10, the value 10 is used instead. */ autoSelectFamilyAttemptTimeout: ?number; + /* Set to `true` to disable validation of index fields. When disabled, indexes can be created even if the fields do not exist in the schema. This can be useful when creating indexes on fields that will be added later. */ + disableIndexFieldValidation: ?boolean; } export interface AuthAdapter {