clean dynamic zone components create

This commit is contained in:
Marc-Roig 2023-02-06 15:46:30 +01:00
parent 02d467f933
commit 71e2c66a2c

View File

@ -82,19 +82,21 @@ const createComponents = async (uid, data) => {
throw new Error('Expected an array to create repeatable component');
}
const createDynamicZoneComponents = async (value) => {
const { id } = await createComponent(value.__component, value);
return {
id,
__component: value.__component,
__pivot: {
field: attributeName,
},
};
};
// MySQL/MariaDB can cause deadlocks here if concurrency higher than 1
componentBody[attributeName] = await mapAsync(
dynamiczoneValues,
async (value) => {
const { id } = await createComponent(value.__component, value);
return {
id,
__component: value.__component,
__pivot: {
field: attributeName,
},
};
},
createDynamicZoneComponents,
{ concurrency: isDialectMySQL() ? 1 : Infinity }
);