Skip to content

Commit

Permalink
chore: use variable instead of function
Browse files Browse the repository at this point in the history
  • Loading branch information
vkarpov15 committed Mar 31, 2021
1 parent d1a9a1e commit f3cd3a8
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions lib/model.js
Expand Up @@ -1633,14 +1633,12 @@ function _ensureIndexes(model, options, callback) {

const indexFields = utils.clone(index[0]);
const indexOptions = utils.clone(index[1]);
const noText = () => {
for (const key in indexFields) {
if (indexFields[key] == 'text') {
return false;
}
let isTextIndex = false;
for (const key of Object.keys(indexFields)) {
if (indexFields[key] === 'text') {
isTextIndex = true;
}
return true;
};
}
delete indexOptions._autoIndex;
_decorateDiscriminatorIndexOptions(model, indexOptions);
if ('safe' in options) {
Expand All @@ -1660,7 +1658,8 @@ function _ensureIndexes(model, options, callback) {
indexOptions.background = options.background;
}
if (model.schema.options.hasOwnProperty('collation') &&
!indexOptions.hasOwnProperty('collation') && noText()) {
!indexOptions.hasOwnProperty('collation')
!isTextIndex) {
indexOptions.collation = model.schema.options.collation;
}

Expand Down

0 comments on commit f3cd3a8

Please sign in to comment.