Skip to content
This repository has been archived by the owner on Nov 25, 2022. It is now read-only.

Export only maximum 100 entries & utf-8 characters #31

Open
mazero opened this issue Aug 5, 2021 · 8 comments
Open

Export only maximum 100 entries & utf-8 characters #31

mazero opened this issue Aug 5, 2021 · 8 comments

Comments

@mazero
Copy link

mazero commented Aug 5, 2021

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).

@carediary
Copy link

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)"

@JohnnyK84
Copy link

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
Copy link

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
Copy link

JohnnyK84 commented Aug 27, 2021

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 ❤

@mazero
Copy link
Author

mazero commented Aug 27, 2021

_limit = -1 is equal to unlimited @JohnnyK84

@b-emini
Copy link

b-emini commented Sep 1, 2021

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

@deepakrudrapaul
Copy link

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

@R-Sudharsan25
Copy link

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?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants