Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

81
Visualizações
Store multi records with adonis

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)
about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda