0

I'm using sails v 1.0.2 and sails-PostgreSQL adapter. I have a model that has a column of date type that saves current time in the format of timestamp with time zone. how should I do it? previously I created my database in pgAdmin statically but now I don't know how to do it in sails

fariba.j
  • 1,737
  • 7
  • 23
  • 42
  • 1
    I recommend storing the data as a js timestamp as a number and using [momentjs-timezone](https://momentjs.com/timezone/) to handle it once retrieved. – streleck Oct 01 '18 at 19:00
  • 1
    To clarify above, the number is what's stored in the db, but moment-js can be used to help make calculations or format it when you need to display it. – streleck Oct 02 '18 at 18:00

1 Answers1

2

A bit late, but in case anyone else comes across this question, here's how you do it:

dateField: {
    type: 'ref',
    columnType: 'timestamptz'
}
poacher2k
  • 150
  • 1
  • 8