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

296
Views
Se envía la marca de tiempo en mi respuesta de ruta, pero mi tabla en la base de datos no muestra la marca de tiempo

 exports.up = (knex, Promise) => knex.schema.createTable('cohorts', (table) => { table.increments('id') .primary(); table.string('name', 'varchar(6)') .notNullable(); table.string('type', 'varchar(3)') .notNullable(); table.date('q1_start_date') .notNullable(); table.date('q2_start_date') .notNullable(); table.date('q3_start_date') .notNullable(); table.date('q4_start_date') .notNullable(); table.date('graduation_date') .notNullable(); table.integer('campus_id') .notNullable() .references('id') .inTable('campuses') .onDelete('CASCADE'); table.timestamps(true, true); }); exports.down = (knex, Promise) => knex.schema.dropTable('cohorts');

Estoy usando postgresql para hacer mi base de datos en la que uso la fecha en mis migraciones cuando reviso mi tabla en la base de datos, está almacenada en el formato de fecha; sin embargo, al escribir mis rutas en bookshelf.js, esas fechas vienen con la marca de tiempo.

Aquí está mi respuesta con la marca de tiempo.

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

cuando el controlador node-postgres lee el tipo de fecha de la columna de la base de datos, lo convierte automáticamente en objeto de fecha de javascript, que en realidad tiene fecha y hora.

Puede configurar el controlador pg para devolver fechas en formato de cadena si lo desea con este paquete https://github.com/brianc/node-pg-types

El tipo de identificación del tipo de fecha es:

 mikaelle=# select typname, oid, typarray from pg_type where pg_type.typname = 'date' order by oid; typname | oid | typarray ---------+------+---------- date | 1082 | 1182 (1 row)

Y el código para configurar el análisis del tipo se puede hacer así:

 var types = require('pg').types types.setTypeParser(1082, function(val) { return val; // just pass the string })
over 4 years ago · Santiago Trujillo Report
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!