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

181
Vistas
How to index timestamp type with knexjs

I am trying to index created_at and updated_at columns with knex js But when I assign index(), it shows me this error:

Property 'index' does not exist on type 'void'

await knex.schema.createTable('ontario_user_reports', (table) => {
    table.string('user_id').notNullable().index();
    table.timestamps(false, true).index(); // here
    table.string('type').notNullable().index();
});

Can you propose me a correct way to index created_at?

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

0

You should be able to add your index like this:

await knex.schema.createTable('ontario_user_reports', (table) => {
    table.string('user_id').notNullable().index();
    table.timestamps(false, true);
    table.string('type').notNullable().index();

    // Add this line:
    table.index('created_at');
});

Optionally, set a name and additional options using the parameters as described here: https://knexjs.org/#Schema-index

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