-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Decorators are an experimental feature in TypeScript, which is known to have issues. Changes in Parcel means that it can no longer build the app, so their use is blocking updating Parcel to a stable release. This change removes the ORM decorators in favour of defining entities programmatically. I'm hoping that the tests and migration-creating script are enough to have caught any mistakes, but given that areas of the app remain untested, it's hard to be sure. Also, this change has to disable Parcel's scope hoisting, as it renames the entity classes. The rename wasn't a problem when using decorators as the generated code saw the class name left unchanged. Now, however, the ORM breaks if they are changed. Refs #399, parcel-bundler/parcel#7293 (comment), microsoft/TypeScript#27519
- Loading branch information
1 parent
eca52cd
commit e66f0d8
Showing
47 changed files
with
554 additions
and
623 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,20 @@ | ||
import { EntitySchema } from '@mikro-orm/core'; | ||
import { v4 as uuidv4 } from 'uuid'; | ||
import { PrimaryKey, Property, Unique } from '@mikro-orm/core'; | ||
|
||
export abstract class BaseEntity { | ||
@PrimaryKey({ hidden: true }) | ||
id!: number; | ||
|
||
@Property({ type: 'string' }) | ||
@Unique() | ||
uuid = uuidv4(); | ||
|
||
@Property() | ||
createdAt: Date = new Date(); | ||
|
||
@Property({ onUpdate: () => new Date() }) | ||
updatedAt: Date = new Date(); | ||
} | ||
|
||
export const baseEntitySchema = new EntitySchema<BaseEntity>({ | ||
name: 'BaseEntity', | ||
abstract: true, | ||
properties: { | ||
id: { type: 'number', hidden: true, primary: true }, | ||
uuid: { type: 'string', unique: true }, | ||
createdAt: { type: 'Date' }, | ||
updatedAt: { type: 'Date', onUpdate: () => new Date() }, | ||
}, | ||
}); |
This file contains 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
Oops, something went wrong.