Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

77
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!