I'm adding ~50k cars in the database but it seems that AWS only allows max of 25 writes at the same time. How can I avoid this limitation using javascript?
My array cars have 50k records and I need to use a splitter to call the method batchWrite with 25 records, and process 25 by 25 records
addCars: async function (cars) {
const putRequests = cars.map((car) => {
return {
PutRequest: {
Item: car,
},
};
});
const params = {
RequestItems: {
[this.carsTable]: putRequests,
}
};
await documentClient.batchWrite(params).promise();
}
ERROR:
Map value must satisfy constraint: [Member must have length less than
or equal to 25, Member must have length greater than or equal to 1]