synchronize: truein your connection options:
defaultcolumn option supports a function. If you are passing a function which returns a string, it will use that string as a default value without escaping it. For example:
one-to-onerelation. Let's say we have two entities:
@JoinColumnwhich is incorrect. Why? Because to make a real relation, we need to create a column in the database. We need to create a column
user. But which column should be created -
photoId? TypeORM cannot decide for you. To make a decision, you must use
@JoinColumnon one of the sides. If you put
Photothen a column called
userIdwill be created in the
phototable. If you put
Userthen a column called
photoIdwill be created in the
usertable. The side with
@JoinColumnwill be called the "owner side of the relationship". The other side of the relation, without
@JoinColumn, is called the "inverse (non-owner) side of relationship".
@ManyToManyrelation. You use
@JoinTableto show the owner side of the relation.
@JoinColumnis not necessary because both decorators are different, and the table where you put the
@ManyToOnedecorator will have the relational column.
@JoinTabledecorators can also be used to specify additional join column / junction table settings, like join column name or junction table name.
outDircompiler option, don't forget to copy assets and resources your app is using into the output directory. Otherwise, make sure to setup correct paths to those assets.
Postentity and rename it to
Blog, you no longer have
Post.tsin your project. However,
Post.jsis left inside the output directory. Now, when TypeORM reads entities from your output directory, it sees two entities -
Blog. This may be a source of bugs. That's why when you remove and move entities with
outDirenabled, it's strongly recommended to remove your output directory and recompile the project again.
entryconfiguration for the migration files only.
mode: 'production', files are optimized by default which includes mangling your code in order to minimize file sizes. This breaks the migrations because TypeORM relies on their names to determine which has already been executed. You may disable minimization completely by adding:
UglifyJsPlugin, you can tell it to not change class or function names like so:
ormconfigfile, the transpiled migration files are included: