So i want to use momentjs instead of Date for my records and this is how I was able to get it typeorm to work:
@BeforeInsert() _setDt() {this.date = this.date.toDate() as any}
@BeforeUpdate() _setDt1() {this.date = this.date.toDate() as any}
@AfterLoad() _setDt2() {this.date = moment(this.date)}
@Column({ type: "date", nullable: false }) date: moment.Moment
it would be great if there was a first class column option for setting up our own marshalling and unmarshalling so we didn't have to break types with as any
@Column({
type: "date",
nullable: false,
marshaller: {
toDb: d => d.toDate(),
fromDb: d => moment(d)
}
}) date: moment.Moment
So i want to use momentjs instead of Date for my records and this is how I was able to get it typeorm to work:
it would be great if there was a first class column option for setting up our own marshalling and unmarshalling so we didn't have to break types with
as any