Skip to content

Commit

Permalink
should work and is designed to handle multiple text fields
Browse files Browse the repository at this point in the history
  • Loading branch information
IslandRhythms committed Mar 24, 2021
1 parent c4897f9 commit f231d7b
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions lib/model.js
Expand Up @@ -1633,9 +1633,15 @@ function _ensureIndexes(model, options, callback) {

const indexFields = utils.clone(index[0]);
const indexOptions = utils.clone(index[1]);
const textBlock = Object.keys(indexFields).map(function(key) {
return indexFields[key];
});
const textBlock = () => {
const results = Object.keys(indexFields).map(function(key) {
return indexFields[key];
});
if (!results.includes('text')) {
return true;
}
return false;
};
delete indexOptions._autoIndex;
_decorateDiscriminatorIndexOptions(model, indexOptions);
if ('safe' in options) {
Expand All @@ -1655,7 +1661,7 @@ function _ensureIndexes(model, options, callback) {
indexOptions.background = options.background;
}
if (model.schema.options.hasOwnProperty('collation') &&
!indexOptions.hasOwnProperty('collation') && textBlock != 'text') {
!indexOptions.hasOwnProperty('collation') && textBlock()) {
indexOptions.collation = model.schema.options.collation;
}

Expand Down

0 comments on commit f231d7b

Please sign in to comment.