Skip to content

Commit

Permalink
Merge pull request #5578 from diogotcorreia/fix/#5577
Browse files Browse the repository at this point in the history
Make UID searchable in Mongoose and avoid errors if content type can't be searched
  • Loading branch information
alexandrebodin committed Mar 23, 2020
2 parents 826bb8a + 400893f commit ce7db06
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions packages/strapi-connector-mongoose/lib/queries.js
Original file line number Diff line number Diff line change
Expand Up @@ -506,6 +506,7 @@ module.exports = ({ model, modelKey, strapi }) => {
const filters = modelUtils.convertParams(modelKey, params);

const $or = buildSearchOr(model, params._q);
if ($or.length === 0) return Promise.resolve([]);

return model
.find({ $or })
Expand All @@ -518,6 +519,7 @@ module.exports = ({ model, modelKey, strapi }) => {

function countSearch(params) {
const $or = buildSearchOr(model, params._q);
if ($or.length === 0) return Promise.resolve(0);
return model.find({ $or }).countDocuments();
}

Expand Down Expand Up @@ -547,6 +549,7 @@ const buildSearchOr = (model, query) => {
case 'string':
case 'text':
case 'password':
case 'uid':
return acc.concat({ [curr]: { $regex: query, $options: 'i' } });
case 'boolean':
if (query === 'true' || query === 'false') {
Expand Down

0 comments on commit ce7db06

Please sign in to comment.