Fix _q count. still does nott work with group by

This commit is contained in:
Alexandre Bodin 2019-09-16 23:06:04 +02:00
parent c1f818958a
commit 23ab277472

View File

@ -208,10 +208,10 @@ const preProcessGroupByData = function({ result, fieldKey, filters, model }) {
return {
...filters,
where: {
...filters.where || {},
[fieldKey]: value._id
}
}
...(filters.where || {}),
[fieldKey]: value._id,
},
};
},
};
});
@ -244,7 +244,6 @@ const createGroupByFieldsResolver = function(model, fields, name) {
fieldResolver,
fieldKey
) => {
const params = {
...GraphQLQuery.convertToParams(_.omit(filters, 'where')),
...GraphQLQuery.convertToQuery(filters.where),
@ -258,8 +257,6 @@ const createGroupByFieldsResolver = function(model, fields, name) {
_id: `$${fieldKey}`,
});
return preProcessGroupByData({
result,
fieldKey,
@ -359,6 +356,9 @@ const formatConnectionAggregator = function(fields, model, modelName) {
count(obj, options, context) {
const opts = GraphQLQuery.convertToQuery(obj.where);
if (opts._q) { // allow search param
return strapi.query(modelName).countSearch(opts);
}
return strapi.query(modelName).count(opts);
},
totalCount(obj, options, context) {