Skip to content

Instantly share code, notes, and snippets.

@B4nan
Created February 6, 2022 18:18
Show Gist options
  • Save B4nan/2a765e1e762d1f825fa961838bb1d7b4 to your computer and use it in GitHub Desktop.
Save B4nan/2a765e1e762d1f825fa961838bb1d7b4 to your computer and use it in GitHub Desktop.
@Entity()
export class Author {
// only `name` will be considered as required for `em.create()`
[OptionalProps]?: 'createdAt' | 'updatedAt';
@PrimaryKey()
id!: number;
@Property({ defaultRaw: 'current_timestamp()' })
createdAt!: Date;
@Property({ onUpdate: () => new Date(), length: 3, defaultRaw: 'current_timestamp(3)' })
updatedAt!: Date;
@Property()
name!: string;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment