I have destination model and it's have 2 json fields infoBlocksJson and translations and to other fields slug and cover so when one record will be stored in that one record there can be 4-5 infoblocks so i don't really know how to store multi requests in infoblock there is icon then again translations and in translations ge language and en language and in there title and description this will be multi time records i think i need foreach here but don't really know how to use it can someone please help me with this...
const payload = schema.create({
slug: schema.string({}, [
rules.required(),
rules.unique({ table: 'destinations', column: 'slug' }),
]),
cover: schema.file.optional({
size: '2mb',
extnames: ['jpg', 'png', 'gif'],
}),
infoBlocksJson: schema.object().members({
icon: schema.file.optional({
size: '2mb',
extnames: ['jpg', 'png', 'gif'],
}),
translations: schema.object().members({
ge: schema.object().members({
title: schema.string({}, [rules.required()]),
description: schema.string({}, [rules.required()]),
}),
en: schema.object.optional().members({
title: schema.string({}, [rules.required()]),
description: schema.string({}, [rules.required()]),
}),
}),
}),
translations: schema.object().members({
ge: schema.object().members({
title: schema.string({}, [rules.required()]),
description: schema.string({}, [rules.required()]),
}),
en: schema.object.optional().members({
title: schema.string({}, [rules.required()]),
description: schema.string({}, [rules.required()]),
}),
}),
})
const validatedData = await ctx.request.validate({ schema: payload })
const storedDestination = await Destination.create(validatedData)
return ctx.response.json(storedDestination)