mirror of
https://github.com/strapi/strapi.git
synced 2025-12-27 07:03:38 +00:00
Fix CM limited to show only 100 entries (#9118)
* fix mongo count * harmonize code between mongoose and bookshelf * refacto
This commit is contained in:
parent
74933d57c4
commit
70ffd7c65b
@ -4,12 +4,14 @@
|
||||
*/
|
||||
|
||||
const _ = require('lodash');
|
||||
const { omit } = require('lodash/fp');
|
||||
const pmap = require('p-map');
|
||||
const { convertRestQueryParams, buildQuery, escapeQuery } = require('strapi-utils');
|
||||
const { contentTypes: contentTypesUtils } = require('strapi-utils');
|
||||
const { singular } = require('pluralize');
|
||||
|
||||
const { PUBLISHED_AT_ATTRIBUTE } = contentTypesUtils.constants;
|
||||
const pickCountFilters = omit(['sort', 'limit', 'start']);
|
||||
|
||||
module.exports = function createQueryBuilder({ model, strapi }) {
|
||||
/* Utils */
|
||||
@ -77,7 +79,7 @@ module.exports = function createQueryBuilder({ model, strapi }) {
|
||||
* Count entries based on filters
|
||||
*/
|
||||
function count(params = {}) {
|
||||
const filters = convertRestQueryParams(_.omit(params, ['_sort', '_limit', '_start']));
|
||||
const filters = pickCountFilters(convertRestQueryParams(params));
|
||||
|
||||
return model
|
||||
.query(buildQuery({ model, filters }))
|
||||
@ -190,7 +192,8 @@ module.exports = function createQueryBuilder({ model, strapi }) {
|
||||
}
|
||||
|
||||
function countSearch(params) {
|
||||
const filters = convertRestQueryParams(_.omit(params, ['_q', '_sort', '_limit', '_start']));
|
||||
const countParams = omit(['_q'], params);
|
||||
const filters = pickCountFilters(convertRestQueryParams(countParams));
|
||||
|
||||
return model
|
||||
.query(qb => qb.where(buildSearchQuery({ model, params })))
|
||||
|
||||
@ -17,6 +17,7 @@ const { findComponentByGlobalId } = require('./utils/helpers');
|
||||
|
||||
const hasPK = (obj, model) => _.has(obj, model.primaryKey) || _.has(obj, 'id');
|
||||
const getPK = (obj, model) => (_.has(obj, model.primaryKey) ? obj[model.primaryKey] : obj.id);
|
||||
const pickCountFilters = omit(['sort', 'limit', 'start']);
|
||||
|
||||
module.exports = ({ model, strapi }) => {
|
||||
const assocKeys = model.associations.map(ast => ast.alias);
|
||||
@ -430,8 +431,7 @@ module.exports = ({ model, strapi }) => {
|
||||
}
|
||||
|
||||
function count(params, { session = null } = {}) {
|
||||
const countParams = omit(['_sort', '_limit', '_start'], params);
|
||||
const filters = convertRestQueryParams(countParams);
|
||||
const filters = pickCountFilters(convertRestQueryParams(params));
|
||||
|
||||
return buildQuery({ model, filters, session }).count();
|
||||
}
|
||||
@ -534,8 +534,8 @@ module.exports = ({ model, strapi }) => {
|
||||
}
|
||||
|
||||
function countSearch(params, { session = null } = {}) {
|
||||
const countParams = omit(['_sort', '_limit', '_start', '_q'], params);
|
||||
const filters = convertRestQueryParams(countParams);
|
||||
const countParams = omit(['_q'], params);
|
||||
const filters = pickCountFilters(convertRestQueryParams(countParams));
|
||||
|
||||
return buildQuery({
|
||||
model,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user