Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

78
Vistas
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 la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda