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

197
Vistas
Insert record in mysql with adonisjs jsonb field

I'm trying to insert a record where one of the fields is of type JSONB

Below is the format I'm trying to build and at the end the error that is being issued.

The field in question is veiculo

orm is trying to access the inside of the json to try to indetify the field.

It should insert the complete object.

I thank the attention. Thanks.

Post

{
  veiculo: {
    placa: 'PLACA',
    motorista: 'NOME',
    contato: 'CONTATO',
    casa: true,
    horaEntrada: '2022-01-20T05:02:22.000Z'
  },
  fornecedor: 'ALIMENTOS',
  lab: 'sim',
}

Model

import { DateTime } from 'luxon'
import { BaseModel, column } from '@ioc:Adonis/Lucid/Orm'

export default class Produto extends BaseModel {
  @column({ isPrimary: true })
  public id: number

  @column()
  public fornecedor: string

  @column()
  public lab: string

  @column()
  public veiculo: Object

  @column.dateTime({ autoCreate: true })
  public createdAt: DateTime

  @column.dateTime({ autoCreate: true, autoUpdate: true })
  public updatedAt: DateTime

Migration

public async up () {
    this.schema.createTable(this.tableName, (table) => {
      table.increments('id')
      table.string('fornecedor'
      table.string('lab')
      table.jsonb('veiculo')

      /**
       * Uses timestamptz for PostgreSQL and DATETIME2 for MSSQL
       */
      table.timestamp('created_at', { useTz: true })
      table.timestamp('updated_at', { useTz: true })
    })
  }

Error

Error: ER_BAD_FIELD_ERROR: Unknown column 'placa' in 'field list'

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Resolved with await dataNfe.related('items').createMany(items)

about 4 years ago · Juan Pablo Isaza Denunciar
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