Open mazero opened 3 years ago
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)"
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?
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.
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:
BTW Nice work on this plugin ❤
_limit = -1 is equal to unlimited @JohnnyK84
@mazero Maybe you could create a merge request with your solution.
I have created a merge request with the solution mentioned above, It would be great if @EdisonPeM merge it.
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:
- Set the limit to something like 999999
- 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?
Hello,
We have tried your plugin, we find bugs and things that would be cool.
Then, it would be a really good idea to be able to update the existing contents (linked to the id on the new import).