Open dave-ok opened 5 years ago
Is handling date as unix time an option?
Is handling date as unix time an option?
Pls I dont understand. Can you elaborate?
My question was based on the limitations listed for Ionic production builds where date types are seen as objects and eventually converted to object columns instead of date columns
https://github.com/typeorm/ionic-example/issues/3#issuecomment-348122054
Well, I handle dates as unix time (milliseconds since epoch).
Let's say you have:
export class Thing {
@PrimaryColumn({ unique: true })
id: number;
date: number;
}
When you fetch it, you will get date as number type, you can then use new Date(date*1000)
Or you can make a getter that returns a date object:
export class Thing {
@PrimaryColumn({ unique: true })
id: number;
date: number;
getDate(): Date{
return new Date(this.date*1000);
}
}
It's just a suggestion
@AchevezAim Thanks a bunch! Looks like this should work. Date comparison is critical to the project I am working on and with your suggestion I can do just that. I'll get right on it. And thanks again!
@dave-ok Is that working for you? I also like to work on this ORM library and Ionic 4. But not started yet. So how's your experience with this ORM and of course Date manipulation?
Please has anyone found a way around the date datatype problem with ionic production builds. I am building an app which is date-centric and this limitation is a downer cos typeorm has everything I need but this. Please help! I need pointers or suggestions