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

177
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
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