Skip to content

Instantly share code, notes, and snippets.

@dhmlau
Created March 24, 2020 20:48
Show Gist options
  • Save dhmlau/8dda7b6fc57742cd9c4147399878076b to your computer and use it in GitHub Desktop.
Save dhmlau/8dda7b6fc57742cd9c4147399878076b to your computer and use it in GitHub Desktop.
LoopBack 4 - default date set in model
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