Created
March 24, 2020 20:48
-
-
Save dhmlau/8dda7b6fc57742cd9c4147399878076b to your computer and use it in GitHub Desktop.
LoopBack 4 - default date set in model
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import {Entity, model, property} from '@loopback/repository'; | |
import moment from 'moment'; | |
@model() | |
export class Customer extends Entity { | |
@property({ | |
type: 'string', | |
id: true, | |
generated: true, | |
}) | |
id?: string; | |
@property({ | |
type: 'date', | |
default: () => moment().format('YYYY-MM-DDTHH:MMZ'), | |
}) | |
createDate: string; | |
@property({ | |
type: 'string', | |
required: true, | |
}) | |
desc: string; | |
constructor(data?: Partial<Customer>) { | |
super(data); | |
} | |
} | |
export interface CustomerRelations { | |
// describe navigational properties here | |
} | |
export type CustomerWithRelations = Customer & CustomerRelations; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment