strapi-plugin-import-export-content icon indicating copy to clipboard operation
strapi-plugin-import-export-content copied to clipboard

Export only maximum 100 entries & utf-8 characters

Open mazero opened this issue 4 years ago • 8 comments

Hello,

We have tried your plugin, we find bugs and things that would be cool.

  • We can import and export data but when we want to export more than 100 entries, we can't. (issue)
  • For the French, it would be nice to accept all utf-8 characters when doing an import (issue).

Then, it would be a really good idea to be able to update the existing contents (linked to the id on the new import).

mazero avatar Aug 05 '21 09:08 mazero

I am also experiencing the same "We can import and export data but when we want to export more than 100 entries, we can't. (issue)"

carediary avatar Aug 07 '21 01:08 carediary

Just installed this plugin and we have the same problem for exporting. By default we are only getting 100 entries back. Anyone find a work around to fix this?

JohnnyK84 avatar Aug 27 '21 01:08 JohnnyK84

I would say the cap of 100 in the response is due to Strapis default return _limit which is 100 by default. This can be seen in the Swagger documentation when running a get on the same API (only 100 results returned). Adjusting the _limit parameter returns more results. So I guess to fix the _limit parameter on the query which exports the data should include a _limit amount. Unfortunately I don't know where in the code to set this param.

JohnnyK84 avatar Aug 27 '21 02:08 JohnnyK84

OK so I found where this is happening in the src code: In services/exporter/index.js

async function getData(target, options, userAbility) {
  const { uid, attributes } = target;
  const permissionsManager =
    strapi.admin.services.permission.createPermissionsManager({
      ability: userAbility,
      model: uid,
    });

  // Filter content by permissions
  const query = permissionsManager.queryFrom({}, PERMISSIONS.read);
  console.log("QUERY: ", query); // check query data before change
  query._limit = 200; // <<<<< set the return limit here
  console.log("QUERY: ", query); // check query data after change

  const items = await strapi.entityService.find(
    { params: query },
    { model: uid },
  );

  return Array.isArray(items)
    ? items.map((item) => cleanFields(item, options, attributes))
    : [cleanFields(items, options, attributes)];
}

@EdisonPeM In the code above I simply added the _limit param as a key to the object. The exporter then exported >100 rows :) Any chance a fix could be made to either:

  1. Set the limit to something like 999999
  2. Have an input that allows the user to specify the _limit amount

BTW Nice work on this plugin ❤

JohnnyK84 avatar Aug 27 '21 02:08 JohnnyK84

_limit = -1 is equal to unlimited @JohnnyK84

mazero avatar Aug 27 '21 04:08 mazero

@mazero Maybe you could create a merge request with your solution.

b-emini avatar Sep 01 '21 11:09 b-emini

I have created a merge request with the solution mentioned above, It would be great if @EdisonPeM merge it.

deepakrudrapaul avatar Oct 02 '21 13:10 deepakrudrapaul

OK so I found where this is happening in the src code: In services/exporter/index.js

async function getData(target, options, userAbility) {
  const { uid, attributes } = target;
  const permissionsManager =
    strapi.admin.services.permission.createPermissionsManager({
      ability: userAbility,
      model: uid,
    });

  // Filter content by permissions
  const query = permissionsManager.queryFrom({}, PERMISSIONS.read);
  console.log("QUERY: ", query); // check query data before change
  query._limit = 200; // <<<<< set the return limit here
  console.log("QUERY: ", query); // check query data after change

  const items = await strapi.entityService.find(
    { params: query },
    { model: uid },
  );

  return Array.isArray(items)
    ? items.map((item) => cleanFields(item, options, attributes))
    : [cleanFields(items, options, attributes)];
}

@EdisonPeM In the code above I simply added the _limit param as a key to the object. The exporter then exported >100 rows :) Any chance a fix could be made to either:

  1. Set the limit to something like 999999
  2. Have an input that allows the user to specify the _limit amount

BTW Nice work on this plugin ❤

I couldn't find the file you're specifying can you check if its added as a feature because I am stuck at this point. Also should I rebuild after making the change?

R-Sudharsan25 avatar Dec 01 '21 05:12 R-Sudharsan25