Skip to content

Commit fb30e43

Browse files
committed
options
1 parent 4f4580a commit fb30e43

File tree

4 files changed

+57
-2
lines changed

4 files changed

+57
-2
lines changed

src/Adapters/Storage/Mongo/MongoStorageAdapter.js

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,8 +154,19 @@ export class MongoStorageAdapter implements StorageAdapter {
154154
this.enableSchemaHooks = !!mongoOptions.enableSchemaHooks;
155155
this.schemaCacheTtl = mongoOptions.schemaCacheTtl;
156156
this.disableIndexFieldValidation = !!mongoOptions.disableIndexFieldValidation;
157-
for (const key of ['enableSchemaHooks', 'schemaCacheTtl', 'maxTimeMS', 'disableIndexFieldValidation']) {
158-
delete mongoOptions[key];
157+
// Remove Parse Server-specific options that should not be passed to MongoDB client
158+
// Note: We only delete from this._mongoOptions, not from the original mongoOptions object,
159+
// because other components (like DatabaseController) need access to these options
160+
for (const key of [
161+
'enableSchemaHooks',
162+
'schemaCacheTtl',
163+
'maxTimeMS',
164+
'disableIndexFieldValidation',
165+
'createIndexUsername',
166+
'createIndexEmail',
167+
'createIndexEmailVerifyToken',
168+
'createIndexPasswordResetToken',
169+
]) {
159170
delete this._mongoOptions[key];
160171
}
161172
}

src/Options/Definitions.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1101,6 +1101,34 @@ module.exports.DatabaseOptions = {
11011101
'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.',
11021102
action: parsers.numberParser('connectTimeoutMS'),
11031103
},
1104+
createIndexEmail: {
1105+
env: 'PARSE_SERVER_DATABASE_CREATE_INDEX_EMAIL',
1106+
help:
1107+
'Set to `true` to automatically create indexes on the email field of the _User collection on server start. Set to `false` to skip index creation. Default is `true`.<br><br>\u26A0\uFE0F The automatically created index may change in the future to be optimized for the internal usage by Parse Server. Keep this in mind when manually creating this index.',
1108+
action: parsers.booleanParser,
1109+
default: true,
1110+
},
1111+
createIndexEmailVerifyToken: {
1112+
env: 'PARSE_SERVER_DATABASE_CREATE_INDEX_EMAIL_VERIFY_TOKEN',
1113+
help:
1114+
'Set to `true` to automatically create an index on the _email_verify_token field of the _User collection on server start. Set to `false` to skip index creation. Default is `true`.<br><br>\u26A0\uFE0F The automatically created index may change in the future to be optimized for the internal usage by Parse Server. Keep this in mind when manually creating this index.',
1115+
action: parsers.booleanParser,
1116+
default: true,
1117+
},
1118+
createIndexPasswordResetToken: {
1119+
env: 'PARSE_SERVER_DATABASE_CREATE_INDEX_PASSWORD_RESET_TOKEN',
1120+
help:
1121+
'Set to `true` to automatically create an index on the _perishable_token field of the _User collection on server start. Set to `false` to skip index creation. Default is `true`.<br><br>\u26A0\uFE0F The automatically created index may change in the future to be optimized for the internal usage by Parse Server. Keep this in mind when manually creating this index.',
1122+
action: parsers.booleanParser,
1123+
default: true,
1124+
},
1125+
createIndexUsername: {
1126+
env: 'PARSE_SERVER_DATABASE_CREATE_INDEX_USERNAME',
1127+
help:
1128+
'Set to `true` to automatically create indexes on the username field of the _User collection on server start. Set to `false` to skip index creation. Default is `true`.<br><br>\u26A0\uFE0F The automatically created index may change in the future to be optimized for the internal usage by Parse Server. Keep this in mind when manually creating this index.',
1129+
action: parsers.booleanParser,
1130+
default: true,
1131+
},
11041132
disableIndexFieldValidation: {
11051133
env: 'PARSE_SERVER_DATABASE_DISABLE_INDEX_FIELD_VALIDATION',
11061134
help:

src/Options/docs.js

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Options/index.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -632,6 +632,18 @@ export interface DatabaseOptions {
632632
autoSelectFamily: ?boolean;
633633
/* 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. */
634634
autoSelectFamilyAttemptTimeout: ?number;
635+
/* Set to `true` to automatically create indexes on the email field of the _User collection on server start. Set to `false` to skip index creation. Default is `true`.<br><br>⚠️ The automatically created index may change in the future to be optimized for the internal usage by Parse Server. Keep this in mind when manually creating this index.
636+
:DEFAULT: true */
637+
createIndexEmail: ?boolean;
638+
/* Set to `true` to automatically create an index on the _email_verify_token field of the _User collection on server start. Set to `false` to skip index creation. Default is `true`.<br><br>⚠️ The automatically created index may change in the future to be optimized for the internal usage by Parse Server. Keep this in mind when manually creating this index.
639+
:DEFAULT: true */
640+
createIndexEmailVerifyToken: ?boolean;
641+
/* Set to `true` to automatically create an index on the _perishable_token field of the _User collection on server start. Set to `false` to skip index creation. Default is `true`.<br><br>⚠️ The automatically created index may change in the future to be optimized for the internal usage by Parse Server. Keep this in mind when manually creating this index.
642+
:DEFAULT: true */
643+
createIndexPasswordResetToken: ?boolean;
644+
/* Set to `true` to automatically create indexes on the username field of the _User collection on server start. Set to `false` to skip index creation. Default is `true`.<br><br>⚠️ The automatically created index may change in the future to be optimized for the internal usage by Parse Server. Keep this in mind when manually creating this index.
645+
:DEFAULT: true */
646+
createIndexUsername: ?boolean;
635647
/* 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. */
636648
disableIndexFieldValidation: ?boolean;
637649
}

0 commit comments

Comments
 (0)