├── cli.ts ├── temp └── .gitignore ├── docs ├── zh_CN │ ├── changelog.md │ ├── query-runner.md │ ├── internals.md │ ├── entity-metadata.md │ └── delete-query-builder.md ├── query-runner.md ├── index.md ├── internals.md └── entity-metadata.md ├── mod.ts ├── .vscode └── settings.json ├── docker └── hana │ └── hxe-config.json ├── src ├── query-builder │ ├── JoinOptions.ts │ ├── SelectQueryBuilderOption.ts │ ├── SelectQuery.ts │ ├── relation-id │ │ └── RelationIdLoadResult.ts │ ├── relation-count │ │ └── RelationCountLoadResult.ts │ └── result │ │ └── DeleteResult.ts ├── common │ ├── ObjectType.ts │ ├── ObjectLiteral.ts │ └── DeepPartial.ts ├── driver │ ├── types │ │ ├── IsolationLevel.ts │ │ ├── DataTypeDefaults.ts │ │ └── DatabaseType.ts │ ├── Query.ts │ ├── SqlInMemory.ts │ └── expo │ │ └── ExpoConnectionOptions.ts ├── repository │ └── EntityId.ts ├── metadata │ └── types │ │ ├── RelationTypes.ts │ │ ├── DeferrableType.ts │ │ ├── PropertyTypeInFunction.ts │ │ ├── TableTypes.ts │ │ ├── OnUpdateType.ts │ │ ├── TreeTypes.ts │ │ ├── OnDeleteType.ts │ │ └── RelationTypeInFunction.ts ├── logger │ └── LoggerOptions.ts ├── util │ ├── SqlUtils.ts │ └── fs.ts ├── connection │ └── typings.ts ├── decorator │ └── options │ │ ├── TransactionOptions.ts │ │ ├── ColumnHstoreOptions.ts │ │ ├── ColumnEmbeddedOptions.ts │ │ ├── ColumnEnumOptions.ts │ │ ├── ColumnWithLengthOptions.ts │ │ ├── JoinColumnOptions.ts │ │ ├── ValueTransformer.ts │ │ ├── SpatialColumnOptions.ts │ │ └── PrimaryGeneratedColumnUUIDOptions.ts ├── version.ts ├── entity-schema │ ├── EntitySchemaCheckOptions.ts │ ├── EntitySchemaExclusionOptions.ts │ ├── EntitySchemaUniqueOptions.ts │ └── EntitySchema.ts ├── find-options │ ├── operator │ │ ├── IsNull.ts │ │ ├── Any.ts │ │ ├── Equal.ts │ │ ├── In.ts │ │ ├── LessThan.ts │ │ ├── Like.ts │ │ ├── MoreThan.ts │ │ ├── Raw.ts │ │ ├── LessThanOrEqual.ts │ │ ├── MoreThanOrEqual.ts │ │ ├── Between.ts │ │ └── Not.ts │ ├── FindConditions.ts │ ├── FindOperatorType.ts │ └── OrderByCondition.ts ├── metadata-args │ ├── EntitySubscriberMetadataArgs.ts │ ├── NamingStrategyMetadataArgs.ts │ ├── DiscriminatorValueMetadataArgs.ts │ ├── TreeMetadataArgs.ts │ ├── CheckMetadataArgs.ts │ ├── ExclusionMetadataArgs.ts │ └── types │ │ └── ColumnMode.ts ├── error │ ├── NotImplementedError.ts │ ├── EntityColumnNotFound.ts │ ├── QueryRunnerAlreadyReleasedError.ts │ ├── ConnectionNotFoundError.ts │ ├── LockNotSupportedOnGivenDriverError.ts │ ├── PersistedEntityNotFoundError.ts │ ├── TreeRepositoryNotSupportedError.ts │ ├── DriverOptionNotSetError.ts │ ├── OptimisticLockCanNotBeUsedError.ts │ └── MustBeEntityError.ts ├── commands │ └── types.ts └── subscriber │ └── BroadcasterResult.ts ├── resources └── logo_big.png ├── vendor └── https │ └── deno.land │ ├── x │ ├── mysql │ │ └── mod.ts │ ├── dotenv │ │ └── mod.ts │ ├── sqlite │ │ └── mod.ts │ ├── postgres │ │ └── mod.ts │ └── yargs │ │ ├── deno-types.ts │ │ └── deno.ts │ └── std │ ├── fs │ ├── exists.ts │ ├── empty_dir.ts │ ├── ensure_dir.ts │ └── expand_glob.ts │ ├── path │ └── mod.ts │ ├── fmt │ └── colors.ts │ ├── hash │ └── sha256.ts │ ├── async │ └── deferred.ts │ ├── encoding │ ├── utf8.ts │ └── yaml.ts │ └── node │ └── process.ts ├── codecov.yml ├── test ├── functional │ ├── connection-options-reader │ │ └── configs │ │ │ ├── .env │ │ │ ├── test-path-config.js │ │ │ ├── test-path-config-async.js │ │ │ ├── config.yml │ │ │ └── sqlite-memory.ts │ ├── sqljs │ │ ├── sqlite │ │ │ └── test.sqlite │ │ └── entity │ │ │ └── Post.ts │ ├── entity-schema │ │ ├── basic │ │ │ ├── model │ │ │ │ ├── Category.ts │ │ │ │ └── Post.ts │ │ │ └── entity │ │ │ │ └── CategoryEntity.ts │ │ └── target │ │ │ └── model │ │ │ └── Post.ts │ ├── ormconfigs │ │ └── all │ │ │ ├── ormconfig.yml │ │ │ ├── ormconfig.env │ │ │ ├── ormconfig.js │ │ │ └── ormconfig.xml │ ├── repository │ │ ├── basic-methods │ │ │ ├── model │ │ │ │ ├── Question.ts │ │ │ │ └── User.ts │ │ │ ├── schema │ │ │ │ └── user.js │ │ │ └── entity │ │ │ │ └── Category.ts │ │ ├── find-methods │ │ │ └── model │ │ │ │ └── User.ts │ │ ├── find-options-operators │ │ │ └── entity │ │ │ │ └── Post.ts │ │ ├── clear │ │ │ └── entity │ │ │ │ └── Post.ts │ │ ├── find-options │ │ │ └── entity │ │ │ │ ├── User.ts │ │ │ │ └── Category.ts │ │ ├── delete-by-id-and-ids │ │ │ └── entity │ │ │ │ └── Post.ts │ │ └── find-options-relations │ │ │ └── entity │ │ │ └── User.ts │ ├── database-schema │ │ └── column-types │ │ │ ├── mssql │ │ │ └── enum │ │ │ │ └── FruitEnum.ts │ │ │ ├── mysql │ │ │ └── enum │ │ │ │ └── FruitEnum.ts │ │ │ └── sqlite │ │ │ └── enum │ │ │ └── FruitEnum.ts │ ├── columns │ │ ├── embedded-columns │ │ │ └── entity │ │ │ │ └── Information.ts │ │ └── value-transformer │ │ │ └── entity │ │ │ └── View.ts │ ├── table-inheritance │ │ ├── extending │ │ │ └── entity │ │ │ │ ├── Unit.ts │ │ │ │ ├── Content.ts │ │ │ │ └── Post.ts │ │ └── single-table │ │ │ ├── database-option-inherited │ │ │ └── entity │ │ │ │ ├── Employee.ts │ │ │ │ └── Person.ts │ │ │ ├── basic-functionality │ │ │ └── entity │ │ │ │ ├── Student.ts │ │ │ │ ├── Employee.ts │ │ │ │ ├── Accountant.ts │ │ │ │ └── Teacher.ts │ │ │ ├── relations │ │ │ ├── many-to-many │ │ │ │ └── entity │ │ │ │ │ └── Employee.ts │ │ │ └── one-to-many │ │ │ │ └── entity │ │ │ │ └── Employee.ts │ │ │ └── non-virtual-discriminator-column │ │ │ └── entity │ │ │ ├── Employee.ts │ │ │ └── Student.ts │ ├── metadata-builder │ │ ├── metadata-args-storage │ │ │ └── entity │ │ │ │ ├── ContentModule.ts │ │ │ │ ├── Unit.ts │ │ │ │ └── Post.ts │ │ └── column-metadata │ │ │ └── entity │ │ │ └── Subcounters.ts │ ├── embedded │ │ ├── embedded-one-to-one │ │ │ └── entity │ │ │ │ └── Subcounters.ts │ │ ├── embedded-many-to-many-case1 │ │ │ └── entity │ │ │ │ └── Subcounters.ts │ │ ├── embedded-many-to-many-case2 │ │ │ └── entity │ │ │ │ └── Subcounters.ts │ │ ├── embedded-many-to-many-case4 │ │ │ └── entity │ │ │ │ └── Subcounters.ts │ │ ├── embedded-many-to-one-case1 │ │ │ └── entity │ │ │ │ └── Subcounters.ts │ │ ├── embedded-many-to-one-case2 │ │ │ └── entity │ │ │ │ └── Subcounters.ts │ │ ├── embedded-many-to-one-case4 │ │ │ └── entity │ │ │ │ └── Subcounters.ts │ │ ├── basic-functionality │ │ │ └── entity │ │ │ │ └── Counters.ts │ │ ├── embedded-many-to-many-case3 │ │ │ └── entity │ │ │ │ └── Subcounters.ts │ │ ├── embedded-many-to-many-case5 │ │ │ └── entity │ │ │ │ └── Subcounters.ts │ │ ├── embedded-many-to-one-case3 │ │ │ └── entity │ │ │ │ └── Subcounters.ts │ │ ├── embedded-many-to-one-case5 │ │ │ └── entity │ │ │ │ └── Subcounters.ts │ │ ├── embedded-with-special-columns │ │ │ └── entity │ │ │ │ └── Subcounters.ts │ │ ├── prefix │ │ │ └── entity │ │ │ │ └── Counters.ts │ │ └── multiple-primary-columns-with-nested-embed │ │ │ └── entity │ │ │ └── Subcounters.ts │ ├── mongodb │ │ └── basic │ │ │ ├── embedded-columns │ │ │ └── entity │ │ │ │ ├── EditHistory.ts │ │ │ │ ├── ExtraInformation.ts │ │ │ │ └── Information.ts │ │ │ ├── mongo-embeddeds-index │ │ │ └── entity │ │ │ │ └── Information.ts │ │ │ └── array-columns │ │ │ └── entity │ │ │ └── Counters.ts │ ├── uuid │ │ ├── cockroach │ │ │ └── entity │ │ │ │ └── Record.ts │ │ └── postgres │ │ │ └── entity │ │ │ └── Record.ts │ ├── decorators │ │ └── embedded │ │ │ └── entity │ │ │ └── Counters.ts │ ├── connection │ │ ├── modules │ │ │ ├── blog │ │ │ │ ├── schema │ │ │ │ │ └── blog-category.json │ │ │ │ └── entity │ │ │ │ │ └── Blog.ts │ │ │ ├── video │ │ │ │ ├── schema │ │ │ │ │ └── video-category.json │ │ │ │ └── entity │ │ │ │ │ └── Video.ts │ │ │ └── question │ │ │ │ └── schema │ │ │ │ └── question-category.json │ │ ├── schema │ │ │ ├── photo.json │ │ │ └── user.json │ │ └── entity │ │ │ ├── Post.ts │ │ │ └── View.ts │ ├── persistence │ │ └── partial-persist │ │ │ └── entity │ │ │ └── Counters.ts │ ├── relations │ │ └── relation-mapped-to-different-name-column │ │ │ └── entity │ │ │ └── PostDetails.ts │ ├── indices │ │ └── embeddeds-index-test │ │ │ └── entity │ │ │ └── Profile.ts │ ├── query-builder │ │ ├── delete │ │ │ └── entity │ │ │ │ ├── Counters.ts │ │ │ │ └── User.ts │ │ ├── insert │ │ │ └── entity │ │ │ │ ├── Counters.ts │ │ │ │ ├── User.ts │ │ │ │ └── Post.ts │ │ ├── update │ │ │ └── entity │ │ │ │ └── Counters.ts │ │ ├── relation-id │ │ │ ├── many-to-one │ │ │ │ ├── embedded-with-multiple-pk │ │ │ │ │ └── entity │ │ │ │ │ │ ├── User.ts │ │ │ │ │ │ └── Category.ts │ │ │ │ └── embedded │ │ │ │ │ └── entity │ │ │ │ │ └── Post.ts │ │ │ ├── one-to-one │ │ │ │ ├── embedded-with-multiple-pk │ │ │ │ │ └── entity │ │ │ │ │ │ ├── User.ts │ │ │ │ │ │ └── Category.ts │ │ │ │ └── embedded │ │ │ │ │ └── entity │ │ │ │ │ └── Post.ts │ │ │ ├── one-to-many │ │ │ │ └── embedded │ │ │ │ │ └── entity │ │ │ │ │ └── Post.ts │ │ │ └── many-to-many │ │ │ │ └── embedded │ │ │ │ └── entity │ │ │ │ └── Post.ts │ │ ├── distinct-on │ │ │ └── entity │ │ │ │ └── User.ts │ │ ├── join │ │ │ └── entity │ │ │ │ ├── Tag.ts │ │ │ │ └── User.ts │ │ ├── insert-on-conflict │ │ │ └── entity │ │ │ │ └── Post.ts │ │ ├── subquery │ │ │ └── entity │ │ │ │ └── Category.ts │ │ └── enabling-transaction │ │ │ └── entity │ │ │ └── Post.ts │ ├── view-entity │ │ ├── general │ │ │ └── entity │ │ │ │ └── Category.ts │ │ ├── mssql │ │ │ └── entity │ │ │ │ └── Category.ts │ │ ├── mysql │ │ │ └── entity │ │ │ │ └── Category.ts │ │ ├── oracle │ │ │ └── entity │ │ │ │ └── Category.ts │ │ ├── sqlite │ │ │ └── entity │ │ │ │ └── Category.ts │ │ └── postgres │ │ │ └── entity │ │ │ └── Category.ts │ ├── deferrable │ │ └── entity │ │ │ └── Company.ts │ ├── query-runner │ │ └── entity │ │ │ ├── Faculty.ts │ │ │ └── Book.ts │ ├── driver │ │ └── convert-to-entity │ │ │ └── entity │ │ │ └── Post.ts │ ├── schema-builder │ │ └── entity │ │ │ ├── Faculty.ts │ │ │ ├── Question.ts │ │ │ └── Album.ts │ ├── migrations │ │ └── show-command │ │ │ └── migration │ │ │ └── 1530542855524-ExampleMigration.ts │ └── transaction │ │ └── transaction-decorator │ │ └── entity │ │ └── Post.ts ├── github-issues │ ├── 56 │ │ └── entity │ │ │ └── AccessToken.ts │ ├── 80 │ │ └── entity │ │ │ └── Post.ts │ ├── 108 │ │ └── entity │ │ │ ├── User.ts │ │ │ └── Project.ts │ ├── 131 │ │ └── entity │ │ │ ├── Employee.ts │ │ │ └── Student.ts │ ├── 151 │ │ └── entity │ │ │ └── Category.ts │ ├── 174 │ │ └── entity │ │ │ └── Contact.ts │ ├── 182 │ │ └── model │ │ │ └── PostStatus.ts │ ├── 190 │ │ └── entity │ │ │ └── Category.ts │ ├── 204 │ │ └── entity │ │ │ ├── RecordConfig.ts │ │ │ └── RecordData.ts │ ├── 215 │ │ └── entity │ │ │ ├── Author.ts │ │ │ └── Abbreviation.ts │ ├── 300 │ │ └── entity │ │ │ └── Duration.ts │ ├── 306 │ │ └── entity │ │ │ └── Duration.ts │ ├── 352 │ │ └── entity │ │ │ └── Post.ts │ ├── 363 │ │ └── entity │ │ │ ├── Car.ts │ │ │ └── Fruit.ts │ ├── 401 │ │ └── entity │ │ │ └── Group.ts │ ├── 438 │ │ └── entity │ │ │ └── Post.ts │ ├── 463 │ │ └── entity │ │ │ └── Post.ts │ ├── 479 │ │ └── entity │ │ │ └── Car.ts │ ├── 485 │ │ └── entity │ │ │ └── Post.ts │ ├── 493 │ │ └── entity │ │ │ └── Post.ts │ ├── 495 │ │ └── entity │ │ │ └── User.ts │ ├── 521 │ │ └── entity │ │ │ └── Car.ts │ ├── 594 │ │ └── entity │ │ │ └── Post.ts │ ├── 609 │ │ └── entity │ │ │ └── Post.ts │ ├── 620 │ │ └── entity │ │ │ └── Dog.ts │ ├── 660 │ │ └── entity │ │ │ └── User.ts │ ├── 704 │ │ └── entity │ │ │ └── User.ts │ ├── 720 │ │ └── entity │ │ │ └── Message.ts │ ├── 762 │ │ └── entity │ │ │ ├── FooChildMetadata.ts │ │ │ └── FooMetadata.ts │ ├── 778 │ │ └── entity │ │ │ ├── Post.ts │ │ │ ├── Category.ts │ │ │ └── Question.ts │ ├── 813 │ │ └── entity │ │ │ └── Category.ts │ ├── 922 │ │ └── entity │ │ │ └── Post.ts │ ├── 929 │ │ └── entity │ │ │ └── TestEntity.ts │ ├── 1014 │ │ └── entity │ │ │ └── TestEntity.ts │ ├── 1042 │ │ └── entity │ │ │ ├── Profile.ts │ │ │ └── Information.ts │ ├── 1099 │ │ └── entity │ │ │ └── Category.ts │ ├── 1118 │ │ └── entity │ │ │ └── Post.ts │ ├── 1139 │ │ └── entity │ │ │ └── User.ts │ ├── 1147 │ │ └── entity │ │ │ └── Post.ts │ ├── 1178 │ │ └── entity │ │ │ ├── User.ts │ │ │ └── Post.ts │ ├── 1245 │ │ └── entity │ │ │ └── Post.ts │ ├── 1259 │ │ └── entity │ │ │ └── Category.ts │ ├── 1261 │ │ └── entity │ │ │ └── Foo.ts │ ├── 1282 │ │ └── entity │ │ │ └── Category.ts │ ├── 1326 │ │ └── entity │ │ │ ├── User.ts │ │ │ └── SpecificUser.ts │ ├── 1369 │ │ └── entity │ │ │ ├── ConcreteEntity.ts │ │ │ └── AbstractEntity.ts │ ├── 1388 │ │ └── entity │ │ │ └── Post.ts │ ├── 1397 │ │ └── entity │ │ │ └── Post.ts │ ├── 1416 │ │ └── entity │ │ │ └── Author.ts │ ├── 1427 │ │ └── entity │ │ │ └── Post.ts │ ├── 1476 │ │ └── entity │ │ │ ├── Item.ts │ │ │ └── Plan.ts │ ├── 1504 │ │ └── entity │ │ │ ├── TestEntity4.ts │ │ │ └── TestEntity1.ts │ ├── 1545 │ │ └── entity │ │ │ ├── MainModel.ts │ │ │ └── ValidationModel.ts │ ├── 1576 │ │ └── entity │ │ │ └── Category.ts │ ├── 1581 │ │ └── entity │ │ │ ├── Product.ts │ │ │ ├── DeliverySlot.ts │ │ │ └── User.ts │ ├── 1591 │ │ └── entity │ │ │ ├── Photo.ts │ │ │ └── User.ts │ ├── 1600 │ │ └── entity │ │ │ └── User.ts │ ├── 1615 │ │ └── entity │ │ │ └── Post.ts │ ├── 1623 │ │ └── entity │ │ │ └── User.ts │ ├── 1652 │ │ └── entity │ │ │ └── Post.ts │ ├── 1656 │ │ └── entity │ │ │ ├── A.ts │ │ │ ├── B.ts │ │ │ └── C.ts │ ├── 1680 │ │ └── entity │ │ │ └── User.ts │ ├── 1685 │ │ └── entity │ │ │ ├── year.ts │ │ │ └── user.ts │ ├── 1703 │ │ └── entity │ │ │ └── UserEntity.ts │ ├── 1716 │ │ └── entity │ │ │ ├── mysqlEntity.ts │ │ │ └── mariadbEntity.ts │ ├── 1720 │ │ └── entity │ │ │ └── Category.ts │ ├── 1733 │ │ └── entity │ │ │ └── Post.ts │ ├── 1749 │ │ └── entity │ │ │ └── Bar.ts │ ├── 1751 │ │ └── entity │ │ │ └── User.ts │ ├── 1754 │ │ └── entity │ │ │ └── tipo-cliente.ts │ ├── 1758 │ │ └── entity │ │ │ └── Post.ts │ ├── 1788 │ │ └── entity │ │ │ └── Personalization.ts │ ├── 1805 │ │ └── entity │ │ │ └── Account.ts │ ├── 1839 │ │ └── entity │ │ │ └── Category.ts │ ├── 1883 │ │ ├── enum │ │ │ └── FruitEnum.ts │ │ └── entity │ │ │ └── Post.ts │ ├── 1901 │ │ └── entity │ │ │ └── Post.ts │ ├── 1972 │ │ └── entity │ │ │ ├── TournamentParticipant.ts │ │ │ └── User.ts │ ├── 1981 │ │ └── entity │ │ │ └── Product.ts │ ├── 1997 │ │ └── entity │ │ │ └── Post.ts │ ├── 2005 │ │ └── entity │ │ │ └── User.ts │ ├── 2006 │ │ └── entity │ │ │ └── User.ts │ ├── 2067 │ │ └── entity │ │ │ └── User.ts │ ├── 2103 │ │ └── entity │ │ │ ├── Simple.ts │ │ │ └── Complex.ts │ ├── 2128 │ │ └── entity │ │ │ └── Post.ts │ ├── 2199 │ │ └── entity │ │ │ └── Bar.ts │ ├── 2200 │ │ └── entity │ │ │ ├── Contact.ts │ │ │ └── Booking.ts │ ├── 2251 │ │ └── entity │ │ │ └── Bar.ts │ ├── 2287 │ │ └── entity │ │ │ └── Post.ts │ ├── 2313 │ │ └── entity │ │ │ └── Post.ts │ ├── 2364 │ │ └── entity │ │ │ ├── dummy.ts │ │ │ └── dummy2.ts │ ├── 2499 │ │ └── entity │ │ │ └── Foo.ts │ ├── 2557 │ │ └── transformer.ts │ ├── 2693 │ │ └── entity │ │ │ └── user.ts │ ├── 2779 │ │ ├── set.ts │ │ └── entity │ │ │ └── Post.ts │ ├── 2800 │ │ └── entity │ │ │ └── Vehicle.ts │ ├── 2871 │ │ └── documentEnum.ts │ ├── 2965 │ │ └── entity │ │ │ ├── note.ts │ │ │ └── person.ts │ ├── 3142 │ │ └── entity │ │ │ └── Contact.ts │ ├── 3349 │ │ └── entity │ │ │ └── Category.ts │ ├── 3350 │ │ └── entity │ │ │ └── Category.ts │ ├── 3352 │ │ └── entity │ │ │ └── Post.ts │ ├── 3363 │ │ └── entity │ │ │ ├── Post.ts │ │ │ └── Category.ts │ ├── 3374 │ │ └── entity │ │ │ └── Post.ts │ ├── 3379 │ │ └── entity │ │ │ └── Post.ts │ ├── 3496 │ │ └── entity │ │ │ └── Post.ts │ ├── 3588 │ │ └── entity │ │ │ └── mysql.ts │ ├── 3604 │ │ └── entity │ │ │ └── Author.ts │ ├── 3694 │ │ ├── enum │ │ │ └── FruitEnum.ts │ │ └── entity │ │ │ └── Post.ts │ ├── 3702 │ │ └── entity │ │ │ └── LetterBox.ts │ ├── 3828 │ │ └── entity │ │ │ └── Entity.ts │ ├── 3847 │ │ └── entity │ │ │ └── Category.ts │ ├── 3857 │ │ └── entity │ │ │ ├── Men.ts │ │ │ ├── Women.ts │ │ │ └── Person.ts │ ├── 3949 │ │ └── entity │ │ │ └── Post.ts │ ├── 4096 │ │ └── entity │ │ │ └── User.ts │ ├── 4106 │ │ └── entity │ │ │ └── GenderEnum.ts │ ├── 4185 │ │ └── entity │ │ │ └── Post.ts │ ├── 4190 │ │ └── entity │ │ │ ├── Category.ts │ │ │ ├── Profile.ts │ │ │ └── Photo.ts │ ├── 4219 │ │ └── entity │ │ │ └── Photo.ts │ ├── 4220 │ │ └── entity │ │ │ └── User.ts │ ├── 4513 │ │ └── entity │ │ │ └── User.ts │ ├── 4630 │ │ └── entity │ │ │ └── User.ts │ ├── 4697 │ │ └── entity │ │ │ └── config.entity.ts │ ├── 4701 │ │ └── migration │ │ │ ├── 1567759789051-ExampleMigration.ts │ │ │ ├── 1567759832591-ExampleMigrationTwo.ts │ │ │ └── 1571426391120-ExampleMigrationThree.ts │ ├── 4719 │ │ └── entity │ │ │ └── Post.ts │ ├── 4753 │ │ └── entity │ │ │ └── User.ts │ ├── 4782 │ │ └── entity │ │ │ └── Item.ts │ ├── 4842 │ │ └── entity │ │ │ └── Post.ts │ ├── 5004 │ │ └── entity │ │ │ └── Foo.ts │ └── 5174 │ │ └── entity │ │ ├── User.ts │ │ └── Role.ts ├── utils │ └── test-setup.ts ├── deps │ ├── sinon.ts │ ├── global.ts │ └── chai.ts └── other-issues │ ├── inheritance-duplicate-columns │ └── entity │ │ ├── BaseContent.ts │ │ └── BasePost.ts │ ├── hydrate-performance │ └── entity │ │ └── Post.ts │ ├── nested-child-entities │ └── entity │ │ ├── SquadBilliardsTournament.ts │ │ ├── BilliardsTournament.ts │ │ └── TournamentGraph.ts │ ├── take-multiple-pk │ └── entity │ │ └── Role.ts │ ├── preventing-injection │ └── entity │ │ └── Post.ts │ ├── join-empty-relations │ └── entity │ │ └── Author.ts │ ├── limit-with-order-by │ └── entity │ │ └── Category.ts │ ├── escaping-function-parameter │ └── entity │ │ └── Post.ts │ └── mssql-add-column-with-default-value │ └── entity │ └── Post.ts ├── .gitignore ├── sample ├── sample24-schemas │ └── entity │ │ ├── Category.ts │ │ ├── PostDetails.ts │ │ ├── Image.ts │ │ └── Post.ts ├── sample6-abstract-table │ └── entity │ │ └── BasePost.ts ├── sample23-nested-joins │ └── entity │ │ └── Author.ts ├── sample19-one-side-relations │ └── entity │ │ ├── Author.ts │ │ ├── Category.ts │ │ └── PostMetadata.ts ├── sample31-table-prefix │ └── entity │ │ ├── Category.ts │ │ └── Author.ts ├── sample20-join-without-relation │ └── entity │ │ ├── Author.ts │ │ └── Category.ts ├── sample13-everywhere-abstraction │ └── entity │ │ ├── BasePost.ts │ │ └── PostUser.ts ├── sample2-one-to-one │ └── entity │ │ ├── PostCategory.ts │ │ ├── PostImage.ts │ │ ├── PostAuthor.ts │ │ └── PostMetadata.ts ├── sample32-migrations │ └── entity │ │ ├── Author.ts │ │ └── Post.ts ├── sample26-embedded-tables │ └── entity │ │ ├── Counters.ts │ │ ├── Question.ts │ │ └── Post.ts ├── sample3-many-to-one │ └── entity │ │ ├── PostCategory.ts │ │ ├── PostImage.ts │ │ ├── PostAuthor.ts │ │ └── PostMetadata.ts ├── sample33-custom-repository │ └── entity │ │ ├── Author.ts │ │ ├── User.ts │ │ └── Post.ts ├── sample4-many-to-many │ └── entity │ │ ├── PostCategory.ts │ │ ├── PostImage.ts │ │ ├── PostAuthor.ts │ │ └── PostMetadata.ts ├── sample28-single-table-inheritance │ └── entity │ │ ├── Employee.ts │ │ ├── Student.ts │ │ └── Homesitter.ts ├── sample30-default-order-by │ └── entity │ │ └── Category.ts ├── sample12-custom-naming-strategy │ └── entity │ │ └── Post.ts ├── sample10-mixed │ └── entity │ │ ├── Cover.ts │ │ ├── Chapter.ts │ │ └── ImageDetails.ts ├── sample27-composite-primary-keys │ └── entity │ │ └── Post.ts ├── sample16-indexes │ └── entity │ │ └── BasePost.ts ├── sample17-versioning │ └── entity │ │ └── Post.ts ├── sample5-subscribers │ └── entity │ │ └── PostAuthor.ts └── sample7-pagination │ └── entity │ └── PostAuthor.ts ├── tsconfig.json ├── .github └── FUNDING.yml └── .editorconfig /cli.ts: -------------------------------------------------------------------------------- 1 | import "./src/cli.ts"; 2 | -------------------------------------------------------------------------------- /temp/.gitignore: -------------------------------------------------------------------------------- 1 | ** 2 | !.gitignore -------------------------------------------------------------------------------- /docs/zh_CN/changelog.md: -------------------------------------------------------------------------------- 1 | # 更新日志 2 | -------------------------------------------------------------------------------- /mod.ts: -------------------------------------------------------------------------------- 1 | export * from "./src/index.ts"; 2 | -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "deno.enable": true 3 | } 4 | -------------------------------------------------------------------------------- /docker/hana/hxe-config.json: -------------------------------------------------------------------------------- 1 | { 2 | "master_password" : "HXEHana1" 3 | } 4 | -------------------------------------------------------------------------------- /src/query-builder/JoinOptions.ts: -------------------------------------------------------------------------------- 1 | export interface JoinOptions { 2 | limit?: number; 3 | } -------------------------------------------------------------------------------- /docs/zh_CN/query-runner.md: -------------------------------------------------------------------------------- 1 | # Query Runner 2 | 3 | `QueryRunner`用于执行与数据库相关的查询。 4 | 5 | 待定 6 | -------------------------------------------------------------------------------- /resources/logo_big.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/denolib/typeorm/HEAD/resources/logo_big.png -------------------------------------------------------------------------------- /vendor/https/deno.land/x/mysql/mod.ts: -------------------------------------------------------------------------------- 1 | export * from "https://deno.land/x/mysql@v2.7.0/mod.ts"; 2 | -------------------------------------------------------------------------------- /docs/zh_CN/internals.md: -------------------------------------------------------------------------------- 1 | # Internals 2 | 3 | 本指南解释了TypeORM中的工作原理。 4 | 这对我们的贡献者很有用。 5 | 6 | 待定。 7 | -------------------------------------------------------------------------------- /vendor/https/deno.land/std/fs/exists.ts: -------------------------------------------------------------------------------- 1 | export * from "https://deno.land/std@0.85.0/fs/exists.ts"; 2 | -------------------------------------------------------------------------------- /vendor/https/deno.land/std/path/mod.ts: -------------------------------------------------------------------------------- 1 | export * from "https://deno.land/std@0.85.0/path/mod.ts"; 2 | -------------------------------------------------------------------------------- /vendor/https/deno.land/x/dotenv/mod.ts: -------------------------------------------------------------------------------- 1 | export * from "https://deno.land/x/dotenv@v0.5.0/mod.ts"; 2 | -------------------------------------------------------------------------------- /vendor/https/deno.land/x/sqlite/mod.ts: -------------------------------------------------------------------------------- 1 | export * from "https://deno.land/x/sqlite@v2.2.1/mod.ts"; 2 | -------------------------------------------------------------------------------- /codecov.yml: -------------------------------------------------------------------------------- 1 | coverage: 2 | precision: 2 3 | round: down 4 | range: "40...80" 5 | 6 | comment: off 7 | -------------------------------------------------------------------------------- /vendor/https/deno.land/std/fmt/colors.ts: -------------------------------------------------------------------------------- 1 | export * from "https://deno.land/std@0.85.0/fmt/colors.ts"; 2 | -------------------------------------------------------------------------------- /vendor/https/deno.land/std/fs/empty_dir.ts: -------------------------------------------------------------------------------- 1 | export * from "https://deno.land/std@0.85.0/fs/empty_dir.ts"; 2 | -------------------------------------------------------------------------------- /vendor/https/deno.land/std/hash/sha256.ts: -------------------------------------------------------------------------------- 1 | export * from "https://deno.land/std@0.85.0/hash/sha256.ts"; 2 | -------------------------------------------------------------------------------- /vendor/https/deno.land/x/postgres/mod.ts: -------------------------------------------------------------------------------- 1 | export * from "https://deno.land/x/postgres@v0.8.0/mod.ts"; 2 | -------------------------------------------------------------------------------- /vendor/https/deno.land/std/async/deferred.ts: -------------------------------------------------------------------------------- 1 | export * from "https://deno.land/std@0.85.0/async/deferred.ts"; 2 | -------------------------------------------------------------------------------- /vendor/https/deno.land/std/encoding/utf8.ts: -------------------------------------------------------------------------------- 1 | export * from "https://deno.land/std@0.85.0/encoding/utf8.ts"; 2 | -------------------------------------------------------------------------------- /vendor/https/deno.land/std/encoding/yaml.ts: -------------------------------------------------------------------------------- 1 | export * from "https://deno.land/std@0.85.0/encoding/yaml.ts"; 2 | -------------------------------------------------------------------------------- /vendor/https/deno.land/std/fs/ensure_dir.ts: -------------------------------------------------------------------------------- 1 | export * from "https://deno.land/std@0.85.0/fs/ensure_dir.ts"; 2 | -------------------------------------------------------------------------------- /vendor/https/deno.land/std/fs/expand_glob.ts: -------------------------------------------------------------------------------- 1 | export * from "https://deno.land/std@0.85.0/fs/expand_glob.ts"; 2 | -------------------------------------------------------------------------------- /docs/query-runner.md: -------------------------------------------------------------------------------- 1 | # Query Runner 2 | 3 | `QueryRunner` is used to perform database-related queries. 4 | 5 | TBD. -------------------------------------------------------------------------------- /test/functional/connection-options-reader/configs/.env: -------------------------------------------------------------------------------- 1 | TYPEORM_CONNECTION = mysql 2 | TYPEORM_DATABASE = test-js 3 | -------------------------------------------------------------------------------- /vendor/https/deno.land/x/yargs/deno-types.ts: -------------------------------------------------------------------------------- 1 | export * from "https://deno.land/x/yargs@v16.2.0-deno/deno-types.ts"; 2 | -------------------------------------------------------------------------------- /src/query-builder/SelectQueryBuilderOption.ts: -------------------------------------------------------------------------------- 1 | export type SelectQueryBuilderOption = "disable-global-order"|"create-pojo"; -------------------------------------------------------------------------------- /test/github-issues/4106/entity/GenderEnum.ts: -------------------------------------------------------------------------------- 1 | export enum Gender { 2 | male = "male", 3 | female = "female" 4 | } 5 | -------------------------------------------------------------------------------- /docs/zh_CN/entity-metadata.md: -------------------------------------------------------------------------------- 1 | # 实体元数据 2 | 3 | 实体元数据和所有相关元数据类包含有关实体,其列、索引、关系以及可用于为TypeORM创建更复杂的应用程序或扩展的其他实体相关信息的信息。 4 | 5 | 待定。 6 | -------------------------------------------------------------------------------- /test/functional/sqljs/sqlite/test.sqlite: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/denolib/typeorm/HEAD/test/functional/sqljs/sqlite/test.sqlite -------------------------------------------------------------------------------- /test/github-issues/182/model/PostStatus.ts: -------------------------------------------------------------------------------- 1 | export enum PostStatus { 2 | NEW = 0, 3 | ACTIVE = 1, 4 | ACHIEVED = 2 5 | } -------------------------------------------------------------------------------- /docs/index.md: -------------------------------------------------------------------------------- 1 | # Documentation 2 | 3 | This directory contains all TypeORM documentation. 4 | This documentation is represented on a site. -------------------------------------------------------------------------------- /test/functional/entity-schema/basic/model/Category.ts: -------------------------------------------------------------------------------- 1 | export interface Category { 2 | 3 | id: number; 4 | name: string; 5 | 6 | } -------------------------------------------------------------------------------- /test/github-issues/2779/set.ts: -------------------------------------------------------------------------------- 1 | export enum Role { 2 | Admin = "Admin", 3 | Support = "Support", 4 | Developer = "Developer" 5 | } -------------------------------------------------------------------------------- /src/common/ObjectType.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Represents some Type of the Object. 3 | */ 4 | export type ObjectType = { new (): T }|Function; 5 | -------------------------------------------------------------------------------- /src/driver/types/IsolationLevel.ts: -------------------------------------------------------------------------------- 1 | export type IsolationLevel = "READ UNCOMMITTED" | "READ COMMITTED" | "REPEATABLE READ" | "SERIALIZABLE"; 2 | -------------------------------------------------------------------------------- /src/repository/EntityId.ts: -------------------------------------------------------------------------------- 1 | import {ObjectID} from "../driver/mongodb/typings.ts"; 2 | 3 | export type EntityId = string|number|Date|ObjectID; 4 | -------------------------------------------------------------------------------- /docs/internals.md: -------------------------------------------------------------------------------- 1 | # Internals 2 | 3 | This guide explains how things are working in TypeORM. 4 | It will be useful for our contributors. 5 | 6 | TBD. -------------------------------------------------------------------------------- /src/query-builder/SelectQuery.ts: -------------------------------------------------------------------------------- 1 | export interface SelectQuery { 2 | selection: string; 3 | aliasName?: string; 4 | virtual?: boolean; 5 | } -------------------------------------------------------------------------------- /test/functional/entity-schema/target/model/Post.ts: -------------------------------------------------------------------------------- 1 | export class Post { 2 | 3 | id!: number; 4 | title!: string; 5 | text!: string; 6 | 7 | } 8 | -------------------------------------------------------------------------------- /test/functional/ormconfigs/all/ormconfig.yml: -------------------------------------------------------------------------------- 1 | default: 2 | host: localhost 3 | username: root 4 | password: admin 5 | port: 3000 6 | logging: true -------------------------------------------------------------------------------- /test/functional/repository/basic-methods/model/Question.ts: -------------------------------------------------------------------------------- 1 | export interface Question { 2 | id?: number; 3 | title?: string; 4 | type: string; 5 | } -------------------------------------------------------------------------------- /test/github-issues/1883/enum/FruitEnum.ts: -------------------------------------------------------------------------------- 1 | export enum FruitEnum { 2 | Apple = "apple", 3 | Pineapple = "pineapple", 4 | Banana = "banana" 5 | } -------------------------------------------------------------------------------- /test/functional/repository/find-methods/model/User.ts: -------------------------------------------------------------------------------- 1 | export interface User { 2 | id: number; 3 | firstName: string; 4 | secondName: string; 5 | } 6 | -------------------------------------------------------------------------------- /test/github-issues/1042/entity/Profile.ts: -------------------------------------------------------------------------------- 1 | export class Profile { 2 | 3 | firstName!: string; 4 | lastName!: string; 5 | age!: number; 6 | 7 | } 8 | -------------------------------------------------------------------------------- /test/github-issues/3694/enum/FruitEnum.ts: -------------------------------------------------------------------------------- 1 | export enum FruitEnum { 2 | Apple = "apple", 3 | Pineapple = "pineapple", 4 | Banana = "banana" 5 | } 6 | -------------------------------------------------------------------------------- /test/functional/connection-options-reader/configs/test-path-config.js: -------------------------------------------------------------------------------- 1 | export default [{ 2 | type: "sqlite", 3 | name: "file", 4 | database: "test-js" 5 | }]; 6 | -------------------------------------------------------------------------------- /test/functional/repository/basic-methods/model/User.ts: -------------------------------------------------------------------------------- 1 | export interface User { 2 | id?: number|null; 3 | firstName?: string; 4 | secondName?: string; 5 | } -------------------------------------------------------------------------------- /src/metadata/types/RelationTypes.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * All types that relation can be. 3 | */ 4 | export type RelationType = "one-to-one"|"one-to-many"|"many-to-one"|"many-to-many"; -------------------------------------------------------------------------------- /src/logger/LoggerOptions.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Logging options. 3 | */ 4 | export type LoggerOptions = boolean|"all"|("query"|"schema"|"error"|"warn"|"info"|"log"|"migration")[]; 5 | -------------------------------------------------------------------------------- /src/util/SqlUtils.ts: -------------------------------------------------------------------------------- 1 | export class SqlUtils { 2 | static isInsertQuery(query: string) : boolean { 3 | return query.substr(0, 11) === "INSERT INTO"; 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /test/functional/ormconfigs/all/ormconfig.env: -------------------------------------------------------------------------------- 1 | TYPEORM_HOST = localhost 2 | TYPEORM_USERNAME = root 3 | TYPEORM_PASSWORD = admin 4 | TYPEORM_PORT = 3000 5 | TYPEORM_LOGGING = true -------------------------------------------------------------------------------- /src/common/ObjectLiteral.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Interface of the simple literal object with any string keys. 3 | */ 4 | export interface ObjectLiteral { 5 | [key: string]: any; 6 | } 7 | -------------------------------------------------------------------------------- /test/functional/database-schema/column-types/mssql/enum/FruitEnum.ts: -------------------------------------------------------------------------------- 1 | export enum FruitEnum { 2 | Apple = "apple", 3 | Pineapple = "pineapple", 4 | Banana = "banana" 5 | } -------------------------------------------------------------------------------- /test/functional/database-schema/column-types/mysql/enum/FruitEnum.ts: -------------------------------------------------------------------------------- 1 | export enum FruitEnum { 2 | Apple = "apple", 3 | Pineapple = "pineapple", 4 | Banana = "banana" 5 | } -------------------------------------------------------------------------------- /test/functional/database-schema/column-types/sqlite/enum/FruitEnum.ts: -------------------------------------------------------------------------------- 1 | export enum FruitEnum { 2 | Apple = "apple", 3 | Pineapple = "pineapple", 4 | Banana = "banana" 5 | } -------------------------------------------------------------------------------- /vendor/https/deno.land/std/node/process.ts: -------------------------------------------------------------------------------- 1 | export * from "https://deno.land/std@0.85.0/node/process.ts"; 2 | export { default } from "https://deno.land/std@0.85.0/node/process.ts"; 3 | -------------------------------------------------------------------------------- /vendor/https/deno.land/x/yargs/deno.ts: -------------------------------------------------------------------------------- 1 | export * from "https://deno.land/x/yargs@v16.2.0-deno/deno.ts"; 2 | export { default } from "https://deno.land/x/yargs@v16.2.0-deno/deno.ts"; 3 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .nyc_output/ 2 | .DS_Store 3 | .idea/ 4 | build/ 5 | coverage/ 6 | node_modules/ 7 | ormconfig.json 8 | ormlogs.log 9 | npm-debug.log 10 | /test/github-issues/799/tmp/* 11 | -------------------------------------------------------------------------------- /sample/sample24-schemas/entity/Category.ts: -------------------------------------------------------------------------------- 1 | import {Post} from "./Post"; 2 | 3 | export interface Category { 4 | 5 | id?: number; 6 | description: string; 7 | posts?: Post[]; 8 | 9 | } -------------------------------------------------------------------------------- /test/functional/connection-options-reader/configs/test-path-config-async.js: -------------------------------------------------------------------------------- 1 | export default Promise.resolve({ 2 | type: "sqlite", 3 | name: "file", 4 | database: "test-js-async" 5 | }); 6 | -------------------------------------------------------------------------------- /src/driver/Query.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This class stores query and its parameters 3 | */ 4 | export class Query { 5 | constructor(public query: string, public parameters?: any[]) { 6 | 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /test/functional/ormconfigs/all/ormconfig.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | name: "default", 3 | host: "localhost", 4 | username: "root", 5 | password: "admin", 6 | port: 3000, 7 | logging: true 8 | }; -------------------------------------------------------------------------------- /test/github-issues/3142/entity/Contact.ts: -------------------------------------------------------------------------------- 1 | import {Column} from "../../../../src/index.ts"; 2 | 3 | export class Contact { 4 | 5 | @Column({ type: String, unique: true }) 6 | email!: string; 7 | } 8 | -------------------------------------------------------------------------------- /src/connection/typings.ts: -------------------------------------------------------------------------------- 1 | // TODO We want to generate this file automatically. 2 | export type Dotenv = { 3 | config(opts?: { 4 | path?: string; 5 | export?: boolean; 6 | }): void 7 | }; 8 | -------------------------------------------------------------------------------- /src/metadata/types/DeferrableType.ts: -------------------------------------------------------------------------------- 1 | 2 | /** 3 | * DEFERRABLE type to be used to specify if foreign key constraints can be deferred. 4 | */ 5 | export type DeferrableType = "INITIALLY IMMEDIATE"|"INITIALLY DEFERRED"; 6 | -------------------------------------------------------------------------------- /test/functional/connection-options-reader/configs/config.yml: -------------------------------------------------------------------------------- 1 | default: 2 | type: "sqlite" 3 | database: "sqlitedb" 4 | sample: 5 | type: "mysql" 6 | database: "mysqldb" 7 | username: "test" 8 | password: "test" -------------------------------------------------------------------------------- /test/github-issues/2871/documentEnum.ts: -------------------------------------------------------------------------------- 1 | export enum DocumentEnum { 2 | NONE = "", 3 | DOCUMENT_A = "DOCUMENT_A", 4 | DOCUMENT_B = "DOCUMENT_B", 5 | DOCUMENT_C = "DOCUMENT_C", 6 | DOCUMENT_D = "DOCUMENT_D", 7 | } -------------------------------------------------------------------------------- /src/metadata/types/PropertyTypeInFunction.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Contains the name of the property of the object, or the function that returns this name. 3 | */ 4 | export type PropertyTypeFactory = string|((t: T) => string|any); 5 | -------------------------------------------------------------------------------- /src/metadata/types/TableTypes.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Table type. Tables can be abstract, closure, junction, embedded, etc. 3 | */ 4 | export type TableType = "regular"|"view"|"junction"|"closure"|"closure-junction"|"entity-child"; 5 | -------------------------------------------------------------------------------- /sample/sample24-schemas/entity/PostDetails.ts: -------------------------------------------------------------------------------- 1 | import {Post} from "./Post"; 2 | 3 | export interface PostDetails { 4 | 5 | id?: number; 6 | metadata: string; 7 | comment: string; 8 | post?: Post; 9 | 10 | } -------------------------------------------------------------------------------- /src/driver/types/DataTypeDefaults.ts: -------------------------------------------------------------------------------- 1 | export interface DataTypeDefaults { 2 | [type: string]: { 3 | length?: number; 4 | width?: number; 5 | precision?: number; 6 | scale?: number; 7 | }; 8 | } -------------------------------------------------------------------------------- /src/metadata/types/OnUpdateType.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * ON_UPDATE type to be used to specify update strategy when some relation is being updated. 3 | */ 4 | export type OnUpdateType = "RESTRICT"|"CASCADE"|"SET NULL"|"DEFAULT"|"NO ACTION"; 5 | -------------------------------------------------------------------------------- /src/metadata/types/TreeTypes.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Tree type. 3 | * Specifies what table pattern will be used for the tree entity. 4 | */ 5 | export type TreeType = "adjacency-list"|"closure-table"|"nested-set"|"materialized-path"; 6 | -------------------------------------------------------------------------------- /test/utils/test-setup.ts: -------------------------------------------------------------------------------- 1 | import "source-map-support/register"; 2 | import "reflect-metadata"; 3 | import * as chai from "chai"; 4 | 5 | chai.should(); 6 | chai.use(require("sinon-chai")); 7 | chai.use(require("chai-as-promised")); -------------------------------------------------------------------------------- /src/decorator/options/TransactionOptions.ts: -------------------------------------------------------------------------------- 1 | import { IsolationLevel } from "../../driver/types/IsolationLevel.ts"; 2 | 3 | export interface TransactionOptions { 4 | connectionName?: string; 5 | isolation?: IsolationLevel; 6 | } 7 | -------------------------------------------------------------------------------- /test/deps/sinon.ts: -------------------------------------------------------------------------------- 1 | // @deno-types="https://unpkg.com/@types/sinon@2.3.0/index.d.ts" 2 | import sinon from "https://dev.jspm.io/sinon@8.1.1"; 3 | //import sinon from 'https://cdn.pika.dev/sinon@^8.1.1'; 4 | 5 | export default sinon; 6 | -------------------------------------------------------------------------------- /sample/sample24-schemas/entity/Image.ts: -------------------------------------------------------------------------------- 1 | import {Post} from "./Post"; 2 | 3 | export interface Image { 4 | 5 | id?: number; 6 | name: string; 7 | url: string; 8 | post?: Post; 9 | secondaryPost?: Post; 10 | 11 | } -------------------------------------------------------------------------------- /test/github-issues/1758/entity/Post.ts: -------------------------------------------------------------------------------- 1 | import {Entity, PrimaryGeneratedColumn} from "../../../../src/index.ts"; 2 | 3 | @Entity() 4 | export class Post { 5 | 6 | @PrimaryGeneratedColumn() 7 | id!: number; 8 | 9 | } 10 | -------------------------------------------------------------------------------- /test/github-issues/2067/entity/User.ts: -------------------------------------------------------------------------------- 1 | import {Entity, PrimaryGeneratedColumn} from "../../../../src/index.ts"; 2 | 3 | @Entity() 4 | export class User { 5 | 6 | @PrimaryGeneratedColumn() 7 | id!: number; 8 | 9 | } 10 | -------------------------------------------------------------------------------- /src/query-builder/relation-id/RelationIdLoadResult.ts: -------------------------------------------------------------------------------- 1 | import {RelationIdAttribute} from "./RelationIdAttribute.ts"; 2 | 3 | export interface RelationIdLoadResult { 4 | relationIdAttribute: RelationIdAttribute; 5 | results: any[]; 6 | } 7 | -------------------------------------------------------------------------------- /test/github-issues/1099/entity/Category.ts: -------------------------------------------------------------------------------- 1 | import {Entity, PrimaryGeneratedColumn} from "../../../../src/index.ts"; 2 | 3 | @Entity() 4 | export class Category { 5 | 6 | @PrimaryGeneratedColumn() 7 | id!: number; 8 | 9 | } 10 | -------------------------------------------------------------------------------- /test/github-issues/1259/entity/Category.ts: -------------------------------------------------------------------------------- 1 | import {Entity, PrimaryGeneratedColumn} from "../../../../src/index.ts"; 2 | 3 | @Entity() 4 | export class Category { 5 | 6 | @PrimaryGeneratedColumn() 7 | id!: number; 8 | 9 | } 10 | -------------------------------------------------------------------------------- /test/github-issues/1282/entity/Category.ts: -------------------------------------------------------------------------------- 1 | import {Entity, PrimaryGeneratedColumn} from "../../../../src/index.ts"; 2 | 3 | @Entity() 4 | export class Category { 5 | 6 | @PrimaryGeneratedColumn() 7 | id!: number; 8 | 9 | } 10 | -------------------------------------------------------------------------------- /test/github-issues/3847/entity/Category.ts: -------------------------------------------------------------------------------- 1 | import {Entity, PrimaryGeneratedColumn} from "../../../../src/index.ts"; 2 | 3 | @Entity() 4 | export class Category { 5 | 6 | @PrimaryGeneratedColumn() 7 | id!: number; 8 | 9 | } 10 | -------------------------------------------------------------------------------- /test/github-issues/813/entity/Category.ts: -------------------------------------------------------------------------------- 1 | import {Entity, PrimaryGeneratedColumn} from "../../../../src/index.ts"; 2 | 3 | @Entity() 4 | export class Category { 5 | 6 | @PrimaryGeneratedColumn() 7 | id!: number; 8 | 9 | } 10 | -------------------------------------------------------------------------------- /test/functional/connection-options-reader/configs/sqlite-memory.ts: -------------------------------------------------------------------------------- 1 | export default [{ 2 | type: "sqlite", 3 | name: "file", 4 | database: "test" 5 | }, { 6 | type: "sqlite", 7 | name: "memory", 8 | database: ":memory:", 9 | }]; 10 | -------------------------------------------------------------------------------- /test/functional/entity-schema/basic/model/Post.ts: -------------------------------------------------------------------------------- 1 | import {Category} from "./Category.ts"; 2 | 3 | export interface Post { 4 | 5 | id: number; 6 | title: string; 7 | text: string; 8 | categories: Category[]; 9 | 10 | } 11 | -------------------------------------------------------------------------------- /src/metadata/types/OnDeleteType.ts: -------------------------------------------------------------------------------- 1 | 2 | /** 3 | * ON_DELETE type to be used to specify delete strategy when some relation is being deleted from the database. 4 | */ 5 | export type OnDeleteType = "RESTRICT"|"CASCADE"|"SET NULL"|"DEFAULT"|"NO ACTION"; 6 | -------------------------------------------------------------------------------- /test/deps/global.ts: -------------------------------------------------------------------------------- 1 | (window as any)['global'] = window; 2 | 3 | // * `window.location` was removed in Deno@v1.0.0-rc1. 4 | // * Mocha depends on `window.location`. 5 | if ((window as any).location == null) { 6 | (window as any).location = {}; 7 | } 8 | -------------------------------------------------------------------------------- /test/deps/chai.ts: -------------------------------------------------------------------------------- 1 | import "./global.ts"; 2 | // @deno-types="https://unpkg.com/@types/chai@4.2.7/index.d.ts" 3 | import "https://unpkg.com/chai@4.2.0/chai.js"; 4 | 5 | chai.should(); 6 | export const expect = chai.expect; 7 | export const should = chai.should; 8 | -------------------------------------------------------------------------------- /test/functional/columns/embedded-columns/entity/Information.ts: -------------------------------------------------------------------------------- 1 | import { Column } from "../../../../../src/decorator/columns/Column.ts"; 2 | 3 | export class Information { 4 | 5 | @Column({ name: "descr", type: String }) 6 | description!: string; 7 | } 8 | -------------------------------------------------------------------------------- /test/functional/table-inheritance/extending/entity/Unit.ts: -------------------------------------------------------------------------------- 1 | import {PrimaryGeneratedColumn} from "../../../../../src/decorator/columns/PrimaryGeneratedColumn.ts"; 2 | 3 | export class Unit { 4 | 5 | @PrimaryGeneratedColumn() 6 | id!: number; 7 | 8 | } 9 | -------------------------------------------------------------------------------- /src/metadata/types/RelationTypeInFunction.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Function that returns a type of the field. Returned value must be a class used on the relation. 3 | */ 4 | export type RelationTypeInFunction = ((type?: any) => Function)|Function|string; // todo: |string ? 5 | 6 | -------------------------------------------------------------------------------- /sample/sample6-abstract-table/entity/BasePost.ts: -------------------------------------------------------------------------------- 1 | import {Column, PrimaryGeneratedColumn} from "../../../src/index"; 2 | 3 | export class BasePost { 4 | 5 | @PrimaryGeneratedColumn() 6 | id: number; 7 | 8 | @Column() 9 | title: string; 10 | 11 | } -------------------------------------------------------------------------------- /src/version.ts: -------------------------------------------------------------------------------- 1 | export const VERSION = "v0.2.23-rc10"; 2 | export const BASE_TYPEORM_VERSION = "v0.2.22"; 3 | export const MOD_URL = `https://denolib.com/denolib/typeorm@${VERSION}/mod.ts`; 4 | export const CLI_URL = `https://denolib.com/denolib/typeorm@${VERSION}/cli.ts`; 5 | -------------------------------------------------------------------------------- /test/github-issues/1805/entity/Account.ts: -------------------------------------------------------------------------------- 1 | import {BaseEntity, Entity, PrimaryColumn} from "../../../../src/index.ts"; 2 | 3 | @Entity("accounts") 4 | export class Account extends BaseEntity { 5 | 6 | @PrimaryColumn("bigint") 7 | id!: string; 8 | 9 | } 10 | -------------------------------------------------------------------------------- /src/driver/SqlInMemory.ts: -------------------------------------------------------------------------------- 1 | import {Query} from "./Query.ts"; 2 | 3 | /** 4 | * This class stores up and down queries needed for migrations functionality. 5 | */ 6 | export class SqlInMemory { 7 | upQueries: Query[] = []; 8 | downQueries: Query[] = []; 9 | } 10 | -------------------------------------------------------------------------------- /test/github-issues/3857/entity/Men.ts: -------------------------------------------------------------------------------- 1 | import {Person} from "./Person.ts"; 2 | import {ChildEntity, Column} from "../../../../src/index.ts"; 3 | 4 | @ChildEntity() 5 | export class Men extends Person { 6 | 7 | @Column("varchar") 8 | beardColor!: string; 9 | } 10 | -------------------------------------------------------------------------------- /test/other-issues/inheritance-duplicate-columns/entity/BaseContent.ts: -------------------------------------------------------------------------------- 1 | import {PrimaryGeneratedColumn} from "../../../../src/decorator/columns/PrimaryGeneratedColumn.ts"; 2 | 3 | export class BaseContent { 4 | 5 | @PrimaryGeneratedColumn() 6 | id!: number; 7 | 8 | } 9 | -------------------------------------------------------------------------------- /src/entity-schema/EntitySchemaCheckOptions.ts: -------------------------------------------------------------------------------- 1 | export interface EntitySchemaCheckOptions { 2 | 3 | /** 4 | * Check constraint name. 5 | */ 6 | name?: string; 7 | 8 | /** 9 | * Check expression. 10 | */ 11 | expression: string; 12 | 13 | } -------------------------------------------------------------------------------- /test/github-issues/3857/entity/Women.ts: -------------------------------------------------------------------------------- 1 | import {Person} from "./Person.ts"; 2 | import {ChildEntity, Column} from "../../../../src/index.ts"; 3 | 4 | @ChildEntity() 5 | export class Women extends Person { 6 | 7 | @Column("int") 8 | brassiereSize!: number; 9 | } 10 | -------------------------------------------------------------------------------- /src/query-builder/relation-count/RelationCountLoadResult.ts: -------------------------------------------------------------------------------- 1 | import {RelationCountAttribute} from "./RelationCountAttribute.ts"; 2 | 3 | export interface RelationCountLoadResult { 4 | relationCountAttribute: RelationCountAttribute; 5 | results: { cnt: any, parentId: any }[]; 6 | } 7 | -------------------------------------------------------------------------------- /test/github-issues/174/entity/Contact.ts: -------------------------------------------------------------------------------- 1 | import {Column} from "../../../../src/decorator/columns/Column.ts"; 2 | 3 | export class Contact { 4 | 5 | @Column({ type: String }) 6 | name!: string; 7 | 8 | @Column({ type: String }) 9 | email!: string; 10 | 11 | } 12 | -------------------------------------------------------------------------------- /test/github-issues/3604/entity/Author.ts: -------------------------------------------------------------------------------- 1 | import {PrimaryGeneratedColumn} from "../../../../src/index.ts"; 2 | import {Entity} from "../../../../src/index.ts"; 3 | 4 | @Entity() 5 | export class Author { 6 | 7 | @PrimaryGeneratedColumn("uuid") 8 | id!: string; 9 | } 10 | -------------------------------------------------------------------------------- /src/find-options/operator/IsNull.ts: -------------------------------------------------------------------------------- 1 | import {FindOperator} from "../FindOperator.ts"; 2 | 3 | /** 4 | * Find Options Operator. 5 | * Example: { someField: IsNull() } 6 | */ 7 | export function IsNull() { 8 | return new FindOperator("isNull", undefined as any, false); 9 | } 10 | -------------------------------------------------------------------------------- /docs/entity-metadata.md: -------------------------------------------------------------------------------- 1 | # Entity Metadata 2 | 3 | Entity metadata and all related metadata classes contain information about entities, 4 | their columns, indices, relations and other entity-related information you can use 5 | to create more complex applications or extensions for TypeORM. 6 | 7 | TBD. -------------------------------------------------------------------------------- /test/functional/table-inheritance/extending/entity/Content.ts: -------------------------------------------------------------------------------- 1 | import {Column} from "../../../../../src/decorator/columns/Column.ts"; 2 | import {Unit} from "./Unit.ts"; 3 | 4 | export class Content extends Unit { 5 | 6 | @Column({ type: String }) 7 | name!: string; 8 | 9 | } 10 | -------------------------------------------------------------------------------- /test/github-issues/1369/entity/ConcreteEntity.ts: -------------------------------------------------------------------------------- 1 | import {Column, Entity} from "../../../../src/index.ts"; 2 | import {AbstractEntity} from "./AbstractEntity.ts"; 3 | 4 | @Entity() 5 | export class ConcreteEntity extends AbstractEntity { 6 | @Column({ type: String }) position!: string; 7 | } 8 | -------------------------------------------------------------------------------- /test/github-issues/4753/entity/User.ts: -------------------------------------------------------------------------------- 1 | import { Entity, Column, PrimaryGeneratedColumn } from "../../../../src/index.ts"; 2 | 3 | @Entity() 4 | export class User { 5 | @PrimaryGeneratedColumn() 6 | id!: number; 7 | 8 | @Column({ type: String }) 9 | name!: string; 10 | } 11 | -------------------------------------------------------------------------------- /sample/sample23-nested-joins/entity/Author.ts: -------------------------------------------------------------------------------- 1 | import {Column, Entity, PrimaryGeneratedColumn} from "../../../src/index"; 2 | 3 | @Entity("sample23_author") 4 | export class Author { 5 | 6 | @PrimaryGeneratedColumn() 7 | id: number; 8 | 9 | @Column() 10 | name: string; 11 | 12 | } -------------------------------------------------------------------------------- /src/entity-schema/EntitySchemaExclusionOptions.ts: -------------------------------------------------------------------------------- 1 | export interface EntitySchemaExclusionOptions { 2 | 3 | /** 4 | * Exclusion constraint name. 5 | */ 6 | name?: string; 7 | 8 | /** 9 | * Exclusion expression. 10 | */ 11 | expression: string; 12 | 13 | } 14 | -------------------------------------------------------------------------------- /src/find-options/operator/Any.ts: -------------------------------------------------------------------------------- 1 | import {FindOperator} from "../FindOperator.ts"; 2 | 3 | /** 4 | * Find Options Operator. 5 | * Example: { someField: Any([...]) } 6 | */ 7 | export function Any(value: T[]|FindOperator) { 8 | return new FindOperator("any", value as any); 9 | } 10 | -------------------------------------------------------------------------------- /src/find-options/operator/Equal.ts: -------------------------------------------------------------------------------- 1 | import {FindOperator} from "../FindOperator.ts"; 2 | 3 | /** 4 | * Find Options Operator. 5 | * Example: { someField: Equal("value") } 6 | */ 7 | export function Equal(value: T|FindOperator) { 8 | return new FindOperator("equal", value); 9 | } 10 | -------------------------------------------------------------------------------- /src/metadata-args/EntitySubscriberMetadataArgs.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Arguments for EntitySubscriberMetadata class. 3 | */ 4 | export interface EntitySubscriberMetadataArgs { 5 | 6 | /** 7 | * Class to which subscriber is applied. 8 | */ 9 | readonly target: Function; 10 | 11 | } 12 | -------------------------------------------------------------------------------- /test/github-issues/1118/entity/Post.ts: -------------------------------------------------------------------------------- 1 | import {Column, Entity, PrimaryGeneratedColumn} from "../../../../src/index.ts"; 2 | 3 | @Entity() 4 | export class Post { 5 | 6 | @PrimaryGeneratedColumn() 7 | id!: number; 8 | 9 | @Column({ type: String }) 10 | name!: string; 11 | } 12 | -------------------------------------------------------------------------------- /test/github-issues/1178/entity/User.ts: -------------------------------------------------------------------------------- 1 | import {Column, Entity, PrimaryGeneratedColumn} from "../../../../src/index.ts"; 2 | 3 | @Entity() 4 | export class User { 5 | 6 | @PrimaryGeneratedColumn() 7 | id!: number; 8 | 9 | @Column({ type: String }) 10 | name!: string; 11 | } 12 | -------------------------------------------------------------------------------- /test/github-issues/4219/entity/Photo.ts: -------------------------------------------------------------------------------- 1 | import {Shim} from "../shim.ts"; 2 | 3 | @Shim.Entity() 4 | export class Photo { 5 | 6 | @Shim.PrimaryGeneratedColumn() 7 | id!: number; 8 | 9 | @Shim.Column({ type: String }) 10 | url!: string; 11 | 12 | user!: any; 13 | 14 | } 15 | -------------------------------------------------------------------------------- /src/find-options/operator/In.ts: -------------------------------------------------------------------------------- 1 | import {FindOperator} from "../FindOperator.ts"; 2 | 3 | /** 4 | * Find Options Operator. 5 | * Example: { someField: In([...]) } 6 | */ 7 | export function In(value: T[]|FindOperator) { 8 | return new FindOperator("in", value as any, true, true); 9 | } 10 | -------------------------------------------------------------------------------- /src/find-options/operator/LessThan.ts: -------------------------------------------------------------------------------- 1 | import {FindOperator} from "../FindOperator.ts"; 2 | 3 | /** 4 | * Find Options Operator. 5 | * Example: { someField: LessThan(10) } 6 | */ 7 | export function LessThan(value: T|FindOperator) { 8 | return new FindOperator("lessThan", value); 9 | } 10 | -------------------------------------------------------------------------------- /src/find-options/operator/Like.ts: -------------------------------------------------------------------------------- 1 | import {FindOperator} from "../FindOperator.ts"; 2 | 3 | /** 4 | * Find Options Operator. 5 | * Example: { someField: Like("%some sting%") } 6 | */ 7 | export function Like(value: T|FindOperator) { 8 | return new FindOperator("like", value); 9 | } 10 | -------------------------------------------------------------------------------- /src/find-options/operator/MoreThan.ts: -------------------------------------------------------------------------------- 1 | import {FindOperator} from "../FindOperator.ts"; 2 | 3 | /** 4 | * Find Options Operator. 5 | * Example: { someField: MoreThan(10) } 6 | */ 7 | export function MoreThan(value: T|FindOperator) { 8 | return new FindOperator("moreThan", value); 9 | } 10 | -------------------------------------------------------------------------------- /test/github-issues/1245/entity/Post.ts: -------------------------------------------------------------------------------- 1 | import {Column, Entity, PrimaryGeneratedColumn} from "../../../../src/index.ts"; 2 | 3 | @Entity() 4 | export class Post { 5 | 6 | @PrimaryGeneratedColumn() 7 | id!: number; 8 | 9 | @Column({ type: String }) 10 | name!: string; 11 | 12 | } 13 | -------------------------------------------------------------------------------- /test/github-issues/1397/entity/Post.ts: -------------------------------------------------------------------------------- 1 | import {Column, Entity, PrimaryGeneratedColumn} from "../../../../src/index.ts"; 2 | 3 | @Entity() 4 | export class Post { 5 | 6 | @PrimaryGeneratedColumn() 7 | id!: number; 8 | 9 | @Column({ type: String }) 10 | title!: string; 11 | 12 | } 13 | -------------------------------------------------------------------------------- /test/github-issues/1476/entity/Item.ts: -------------------------------------------------------------------------------- 1 | import { Entity, PrimaryColumn, Column } from "../../../../src/index.ts"; 2 | 3 | 4 | @Entity() 5 | export class Item { 6 | @PrimaryColumn({ type: Number }) 7 | itemId!: number; 8 | 9 | @Column({ type: Number }) 10 | planId!: number; 11 | } 12 | -------------------------------------------------------------------------------- /test/github-issues/1581/entity/Product.ts: -------------------------------------------------------------------------------- 1 | import {Column, Entity} from "../../../../src/index.ts"; 2 | 3 | @Entity() 4 | export class Product { 5 | 6 | @Column({ type: Number, primary: true }) 7 | id!: number; 8 | 9 | @Column({ type: String }) 10 | name!: string; 11 | 12 | } 13 | -------------------------------------------------------------------------------- /test/github-issues/1788/entity/Personalization.ts: -------------------------------------------------------------------------------- 1 | import { Column, Entity, PrimaryGeneratedColumn } from "../../../../src/index.ts"; 2 | 3 | @Entity() 4 | export class Personalization { 5 | @PrimaryGeneratedColumn("uuid") public id!: number; 6 | 7 | @Column({ type: String }) public logo!: string; 8 | } 9 | -------------------------------------------------------------------------------- /test/github-issues/2103/entity/Simple.ts: -------------------------------------------------------------------------------- 1 | import {Entity, Column, PrimaryGeneratedColumn} from "../../../../src/index.ts"; 2 | 3 | @Entity() 4 | export class Simple { 5 | 6 | @PrimaryGeneratedColumn() 7 | id!: number; 8 | 9 | @Column({ type: Number }) 10 | x!: number; 11 | 12 | } 13 | -------------------------------------------------------------------------------- /test/github-issues/4842/entity/Post.ts: -------------------------------------------------------------------------------- 1 | import {Column, Entity, PrimaryGeneratedColumn} from "../../../../src/index.ts"; 2 | 3 | @Entity() 4 | export class Post { 5 | 6 | @PrimaryGeneratedColumn() 7 | id!: number; 8 | 9 | @Column({ type: String }) 10 | title!: string; 11 | 12 | } 13 | -------------------------------------------------------------------------------- /sample/sample19-one-side-relations/entity/Author.ts: -------------------------------------------------------------------------------- 1 | import {Column, Entity, PrimaryGeneratedColumn} from "../../../src/index"; 2 | 3 | @Entity("sample19_author") 4 | export class Author { 5 | 6 | @PrimaryGeneratedColumn() 7 | id: number; 8 | 9 | @Column() 10 | name: string; 11 | 12 | } -------------------------------------------------------------------------------- /sample/sample31-table-prefix/entity/Category.ts: -------------------------------------------------------------------------------- 1 | import {Column, Entity, PrimaryGeneratedColumn} from "../../../src/index"; 2 | 3 | @Entity("sample31_category") 4 | export class Category { 5 | 6 | @PrimaryGeneratedColumn() 7 | id: number; 8 | 9 | @Column() 10 | name: string; 11 | 12 | } -------------------------------------------------------------------------------- /src/decorator/options/ColumnHstoreOptions.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Column options for enum-typed columns. 3 | */ 4 | export interface ColumnHstoreOptions { 5 | 6 | /** 7 | * Return type of HSTORE column. 8 | * Returns value as string or as object. 9 | */ 10 | hstoreType?: string; 11 | 12 | } -------------------------------------------------------------------------------- /test/github-issues/1476/entity/Plan.ts: -------------------------------------------------------------------------------- 1 | import { Entity, PrimaryColumn, Column } from "../../../../src/index.ts"; 2 | 3 | 4 | @Entity() 5 | export class Plan { 6 | @PrimaryColumn({ type: Number }) 7 | planId!: number; 8 | 9 | @Column({ type: String }) 10 | planName!: string; 11 | } 12 | -------------------------------------------------------------------------------- /test/github-issues/204/entity/RecordConfig.ts: -------------------------------------------------------------------------------- 1 | export interface RecordConfig { 2 | 3 | id: number; 4 | option1: string; 5 | option2: string; 6 | option3: string; 7 | isActive: boolean; 8 | extra: { 9 | data1: string; 10 | data2: string; 11 | }; 12 | 13 | } 14 | -------------------------------------------------------------------------------- /test/github-issues/594/entity/Post.ts: -------------------------------------------------------------------------------- 1 | import {Column, Entity, PrimaryGeneratedColumn} from "../../../../src/index.ts"; 2 | 3 | @Entity() 4 | export class Post { 5 | 6 | @PrimaryGeneratedColumn() 7 | postId!: number; 8 | 9 | @Column({ type: Number }) 10 | modelId!: number; 11 | 12 | } 13 | -------------------------------------------------------------------------------- /sample/sample19-one-side-relations/entity/Category.ts: -------------------------------------------------------------------------------- 1 | import {Column, Entity, PrimaryGeneratedColumn} from "../../../src/index"; 2 | 3 | @Entity("sample19_category") 4 | export class Category { 5 | 6 | @PrimaryGeneratedColumn() 7 | id: number; 8 | 9 | @Column() 10 | name: string; 11 | 12 | } -------------------------------------------------------------------------------- /sample/sample20-join-without-relation/entity/Author.ts: -------------------------------------------------------------------------------- 1 | import {Column, Entity, PrimaryGeneratedColumn} from "../../../src/index"; 2 | 3 | @Entity("sample20_author") 4 | export class Author { 5 | 6 | @PrimaryGeneratedColumn() 7 | id: number; 8 | 9 | @Column() 10 | name: string; 11 | 12 | } -------------------------------------------------------------------------------- /sample/sample20-join-without-relation/entity/Category.ts: -------------------------------------------------------------------------------- 1 | import {Column, Entity, PrimaryGeneratedColumn} from "../../../src/index"; 2 | 3 | @Entity("sample20_category") 4 | export class Category { 5 | 6 | @PrimaryGeneratedColumn() 7 | id: number; 8 | 9 | @Column() 10 | name: string; 11 | 12 | } -------------------------------------------------------------------------------- /test/functional/metadata-builder/metadata-args-storage/entity/ContentModule.ts: -------------------------------------------------------------------------------- 1 | import {Column} from "../../../../../src/decorator/columns/Column.ts"; 2 | import {Unit} from "./Unit.ts"; 3 | 4 | export class ContentModule extends Unit { 5 | 6 | @Column({ type: String }) 7 | tag!: string; 8 | 9 | } 10 | -------------------------------------------------------------------------------- /test/github-issues/4190/entity/Category.ts: -------------------------------------------------------------------------------- 1 | import {Entity, PrimaryGeneratedColumn, Column} from "../../../../src/index.ts"; 2 | 3 | @Entity() 4 | export class Category { 5 | 6 | @PrimaryGeneratedColumn() 7 | id!: number; 8 | 9 | @Column({ type: String }) 10 | name!: string; 11 | 12 | } 13 | -------------------------------------------------------------------------------- /test/functional/ormconfigs/all/ormconfig.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | localhost 4 | root 5 | admin 6 | 3000 7 | true 8 | 9 | -------------------------------------------------------------------------------- /test/github-issues/1139/entity/User.ts: -------------------------------------------------------------------------------- 1 | import { Entity } from "../../../../src/decorator/entity/Entity.ts"; 2 | import { PrimaryGeneratedColumn } from "../../../../src/decorator/columns/PrimaryGeneratedColumn.ts"; 3 | 4 | @Entity() 5 | export class User { 6 | @PrimaryGeneratedColumn("uuid") 7 | id!: string; 8 | } 9 | -------------------------------------------------------------------------------- /test/github-issues/1581/entity/DeliverySlot.ts: -------------------------------------------------------------------------------- 1 | import {Column, Entity, PrimaryGeneratedColumn} from "../../../../src/index.ts"; 2 | 3 | @Entity() 4 | export class DeliverySlot { 5 | 6 | @PrimaryGeneratedColumn() 7 | id!: number; 8 | 9 | @Column({ type: String }) 10 | name!: string; 11 | 12 | } 13 | -------------------------------------------------------------------------------- /test/github-issues/1600/entity/User.ts: -------------------------------------------------------------------------------- 1 | import {Column, Entity, PrimaryGeneratedColumn} from "../../../../src/index.ts"; 2 | 3 | @Entity() 4 | export class User { 5 | 6 | @PrimaryGeneratedColumn() 7 | id!: number; 8 | 9 | @Column("varchar", { array: true }) 10 | names!: string[]; 11 | 12 | } 13 | -------------------------------------------------------------------------------- /test/github-issues/1615/entity/Post.ts: -------------------------------------------------------------------------------- 1 | import {Column, Entity, PrimaryGeneratedColumn} from "../../../../src/index.ts"; 2 | 3 | @Entity("Foo") 4 | export class FooEntity { 5 | 6 | @PrimaryGeneratedColumn() 7 | id!: number; 8 | 9 | @Column("datetime2", { precision: 0 }) 10 | date!: Date; 11 | } 12 | -------------------------------------------------------------------------------- /test/github-issues/1652/entity/Post.ts: -------------------------------------------------------------------------------- 1 | import {Entity, PrimaryColumn, PrimaryGeneratedColumn} from "../../../../src/index.ts"; 2 | 3 | @Entity() 4 | export class Post { 5 | 6 | @PrimaryGeneratedColumn() 7 | id!: number; 8 | 9 | @PrimaryColumn({ type: String }) 10 | name!: string; 11 | 12 | } 13 | -------------------------------------------------------------------------------- /test/github-issues/1680/entity/User.ts: -------------------------------------------------------------------------------- 1 | import {Entity, Column, PrimaryGeneratedColumn} from "../../../../src/index.ts"; 2 | 3 | @Entity() 4 | export class User { 5 | 6 | @PrimaryGeneratedColumn() 7 | id!: number; 8 | 9 | @Column({ type: String, unique: true }) 10 | name!: string; 11 | 12 | } 13 | -------------------------------------------------------------------------------- /test/github-issues/1749/entity/Bar.ts: -------------------------------------------------------------------------------- 1 | import {Entity} from "../../../../src/decorator/entity/Entity.ts"; 2 | import {PrimaryGeneratedColumn} from "../../../../src/index.ts"; 3 | 4 | @Entity("bar", { schema: "foo" }) 5 | export class Bar { 6 | 7 | @PrimaryGeneratedColumn() 8 | id!: string; 9 | 10 | } 11 | -------------------------------------------------------------------------------- /test/github-issues/1981/entity/Product.ts: -------------------------------------------------------------------------------- 1 | import {Column, Entity, PrimaryGeneratedColumn} from "../../../../src/index.ts"; 2 | 3 | @Entity() 4 | export class Product { 5 | 6 | @PrimaryGeneratedColumn("uuid") 7 | id!: string; 8 | 9 | @Column({ type: Boolean }) 10 | liked!: boolean; 11 | 12 | } 13 | -------------------------------------------------------------------------------- /test/functional/embedded/embedded-one-to-one/entity/Subcounters.ts: -------------------------------------------------------------------------------- 1 | import {Column} from "../../../../../src/decorator/columns/Column.ts"; 2 | 3 | export class Subcounters { 4 | 5 | @Column({ type: Number }) 6 | version!: number; 7 | 8 | @Column({ type: Number }) 9 | watches!: number; 10 | 11 | } 12 | -------------------------------------------------------------------------------- /test/functional/mongodb/basic/embedded-columns/entity/EditHistory.ts: -------------------------------------------------------------------------------- 1 | import {Column} from "../../../../../../src/decorator/columns/Column.ts"; 2 | 3 | export class EditHistory { 4 | 5 | @Column({ type: String }) 6 | title!: string; 7 | 8 | @Column({ type: String }) 9 | text!: string; 10 | 11 | } 12 | -------------------------------------------------------------------------------- /test/github-issues/1326/entity/User.ts: -------------------------------------------------------------------------------- 1 | import {Column, Entity, PrimaryGeneratedColumn} from "../../../../src/index.ts"; 2 | 3 | @Entity({ database: "db_1" }) 4 | export class User { 5 | 6 | @PrimaryGeneratedColumn() 7 | id!: number; 8 | 9 | @Column({ type: String }) 10 | name!: string; 11 | 12 | } 13 | -------------------------------------------------------------------------------- /src/find-options/operator/Raw.ts: -------------------------------------------------------------------------------- 1 | import {FindOperator} from "../FindOperator.ts"; 2 | 3 | /** 4 | * Find Options Operator. 5 | * Example: { someField: Raw([...]) } 6 | */ 7 | export function Raw(value: string|((columnAlias?: string) => string)) { 8 | return new FindOperator("raw", value as any, false); 9 | } 10 | -------------------------------------------------------------------------------- /test/functional/embedded/embedded-many-to-many-case1/entity/Subcounters.ts: -------------------------------------------------------------------------------- 1 | import {Column} from "../../../../../src/decorator/columns/Column.ts"; 2 | 3 | export class Subcounters { 4 | 5 | @Column({ type: Number }) 6 | version!: number; 7 | 8 | @Column({ type: Number }) 9 | watches!: number; 10 | 11 | } 12 | -------------------------------------------------------------------------------- /test/functional/embedded/embedded-many-to-many-case2/entity/Subcounters.ts: -------------------------------------------------------------------------------- 1 | import {Column} from "../../../../../src/decorator/columns/Column.ts"; 2 | 3 | export class Subcounters { 4 | 5 | @Column({ type: Number }) 6 | version!: number; 7 | 8 | @Column({ type: Number }) 9 | watches!: number; 10 | 11 | } 12 | -------------------------------------------------------------------------------- /test/functional/embedded/embedded-many-to-many-case4/entity/Subcounters.ts: -------------------------------------------------------------------------------- 1 | import {Column} from "../../../../../src/decorator/columns/Column.ts"; 2 | 3 | export class Subcounters { 4 | 5 | @Column({ type: Number }) 6 | version!: number; 7 | 8 | @Column({ type: Number }) 9 | watches!: number; 10 | 11 | } 12 | -------------------------------------------------------------------------------- /test/functional/embedded/embedded-many-to-one-case1/entity/Subcounters.ts: -------------------------------------------------------------------------------- 1 | import {Column} from "../../../../../src/decorator/columns/Column.ts"; 2 | 3 | export class Subcounters { 4 | 5 | @Column({ type: Number }) 6 | version!: number; 7 | 8 | @Column({ type: Number }) 9 | watches!: number; 10 | 11 | } 12 | -------------------------------------------------------------------------------- /test/functional/embedded/embedded-many-to-one-case2/entity/Subcounters.ts: -------------------------------------------------------------------------------- 1 | import {Column} from "../../../../../src/decorator/columns/Column.ts"; 2 | 3 | export class Subcounters { 4 | 5 | @Column({ type: Number }) 6 | version!: number; 7 | 8 | @Column({ type: Number }) 9 | watches!: number; 10 | 11 | } 12 | -------------------------------------------------------------------------------- /test/functional/embedded/embedded-many-to-one-case4/entity/Subcounters.ts: -------------------------------------------------------------------------------- 1 | import {Column} from "../../../../../src/decorator/columns/Column.ts"; 2 | 3 | export class Subcounters { 4 | 5 | @Column({ type: Number }) 6 | version!: number; 7 | 8 | @Column({ type: Number }) 9 | watches!: number; 10 | 11 | } 12 | -------------------------------------------------------------------------------- /test/functional/metadata-builder/column-metadata/entity/Subcounters.ts: -------------------------------------------------------------------------------- 1 | import {Column} from "../../../../../src/decorator/columns/Column.ts"; 2 | 3 | export class Subcounters { 4 | 5 | @Column({ type: Number }) 6 | version!: number; 7 | 8 | @Column({ type: Number }) 9 | watches!: number; 10 | 11 | } 12 | -------------------------------------------------------------------------------- /test/functional/mongodb/basic/embedded-columns/entity/ExtraInformation.ts: -------------------------------------------------------------------------------- 1 | import {Column} from "../../../../../../src/decorator/columns/Column.ts"; 2 | import {EditHistory} from "./EditHistory.ts"; 3 | 4 | export class ExtraInformation { 5 | 6 | @Column(type => EditHistory) 7 | lastEdit!: EditHistory; 8 | 9 | } 10 | -------------------------------------------------------------------------------- /test/github-issues/1388/entity/Post.ts: -------------------------------------------------------------------------------- 1 | import {Column, Entity, PrimaryGeneratedColumn} from "../../../../src/index.ts"; 2 | 3 | @Entity() 4 | export class Post { 5 | 6 | @PrimaryGeneratedColumn() 7 | id!: number; 8 | 9 | @Column({ type: "timestamp", nullable: true }) 10 | createdAt!: Date; 11 | 12 | } 13 | -------------------------------------------------------------------------------- /test/github-issues/1427/entity/Post.ts: -------------------------------------------------------------------------------- 1 | import {Column, Entity, PrimaryGeneratedColumn} from "../../../../src/index.ts"; 2 | 3 | @Entity() 4 | export class Post { 5 | 6 | @PrimaryGeneratedColumn() 7 | id!: number; 8 | 9 | @Column({type: "decimal", precision: 10, scale: 6}) 10 | qty!: string; 11 | 12 | } 13 | -------------------------------------------------------------------------------- /test/github-issues/2313/entity/Post.ts: -------------------------------------------------------------------------------- 1 | import {BaseEntity, Entity, PrimaryGeneratedColumn, Column} from "../../../../src/index.ts"; 2 | 3 | @Entity() 4 | export class Post extends BaseEntity { 5 | 6 | @PrimaryGeneratedColumn() 7 | id!: number; 8 | 9 | @Column({ type: Number }) 10 | data!: number; 11 | } 12 | -------------------------------------------------------------------------------- /sample/sample13-everywhere-abstraction/entity/BasePost.ts: -------------------------------------------------------------------------------- 1 | import {Column, PrimaryGeneratedColumn} from "../../../src/index"; 2 | 3 | export class BasePost { 4 | 5 | @PrimaryGeneratedColumn() 6 | id: number; 7 | 8 | @Column() 9 | title: string; 10 | 11 | @Column() 12 | title2312312: string; 13 | 14 | } -------------------------------------------------------------------------------- /sample/sample19-one-side-relations/entity/PostMetadata.ts: -------------------------------------------------------------------------------- 1 | import {Column, Entity, PrimaryGeneratedColumn} from "../../../src/index"; 2 | 3 | @Entity("sample19_post_metadata") 4 | export class PostMetadata { 5 | 6 | @PrimaryGeneratedColumn() 7 | id: number; 8 | 9 | @Column("text") 10 | comment: string; 11 | 12 | } -------------------------------------------------------------------------------- /src/find-options/operator/LessThanOrEqual.ts: -------------------------------------------------------------------------------- 1 | import {FindOperator} from "../FindOperator.ts"; 2 | 3 | /** 4 | * Find Options Operator. 5 | * Example: { someField: LessThanOrEqual(10) } 6 | */ 7 | export function LessThanOrEqual(value: T|FindOperator) { 8 | return new FindOperator("lessThanOrEqual", value); 9 | } 10 | -------------------------------------------------------------------------------- /src/find-options/operator/MoreThanOrEqual.ts: -------------------------------------------------------------------------------- 1 | import {FindOperator} from "../FindOperator.ts"; 2 | 3 | /** 4 | * Find Options Operator. 5 | * Example: { someField: MoreThanOrEqual(10) } 6 | */ 7 | export function MoreThanOrEqual(value: T|FindOperator) { 8 | return new FindOperator("moreThanOrEqual", value); 9 | } 10 | -------------------------------------------------------------------------------- /test/github-issues/438/entity/Post.ts: -------------------------------------------------------------------------------- 1 | import {Column, Entity, PrimaryColumn} from "../../../../src/index.ts"; 2 | 3 | @Entity() 4 | export class Post { 5 | 6 | @PrimaryColumn({ type: Number, unsigned: true }) 7 | id!: number; 8 | 9 | @Column({ type: Number, zerofill: true }) 10 | num!: number; 11 | 12 | } 13 | -------------------------------------------------------------------------------- /test/github-issues/485/entity/Post.ts: -------------------------------------------------------------------------------- 1 | import {Entity} from "../../../../src/decorator/entity/Entity.ts"; 2 | import {PrimaryGeneratedColumn} from "../../../../src/decorator/columns/PrimaryGeneratedColumn.ts"; 3 | 4 | @Entity() 5 | export class Post { 6 | 7 | @PrimaryGeneratedColumn("uuid") 8 | id!: string; 9 | 10 | } 11 | -------------------------------------------------------------------------------- /sample/sample2-one-to-one/entity/PostCategory.ts: -------------------------------------------------------------------------------- 1 | import {Column, Entity, PrimaryGeneratedColumn} from "../../../src/index.ts"; 2 | 3 | @Entity("sample2_post_category") 4 | export class PostCategory { 5 | 6 | @PrimaryGeneratedColumn() 7 | id: number; 8 | 9 | @Column({ type: String }) 10 | name: string; 11 | 12 | } 13 | -------------------------------------------------------------------------------- /sample/sample32-migrations/entity/Author.ts: -------------------------------------------------------------------------------- 1 | import {Column, Entity, PrimaryGeneratedColumn} from "../../../src/index"; 2 | 3 | @Entity() 4 | export class Author { 5 | 6 | @PrimaryGeneratedColumn() 7 | id: number; 8 | 9 | @Column() 10 | firstName: string; 11 | 12 | @Column() 13 | lastName: string; 14 | 15 | } -------------------------------------------------------------------------------- /src/entity-schema/EntitySchemaUniqueOptions.ts: -------------------------------------------------------------------------------- 1 | export interface EntitySchemaUniqueOptions { 2 | 3 | /** 4 | * Unique constraint name. 5 | */ 6 | name?: string; 7 | 8 | /** 9 | * Unique column names. 10 | */ 11 | columns?: ((object?: any) => (any[]|{ [key: string]: number }))|string[]; 12 | 13 | } -------------------------------------------------------------------------------- /src/find-options/FindConditions.ts: -------------------------------------------------------------------------------- 1 | import {FindOperator} from "./FindOperator.ts"; 2 | 3 | /** 4 | * Used for find operations. 5 | */ 6 | export type FindConditions = { 7 | [P in keyof T]?: T[P] extends never ? FindConditions|FindOperator> : FindConditions|FindOperator>; 8 | }; 9 | -------------------------------------------------------------------------------- /test/functional/columns/value-transformer/entity/View.ts: -------------------------------------------------------------------------------- 1 | import { Entity, PrimaryGeneratedColumn, Column } from "../../../../../src/index.ts"; 2 | 3 | @Entity() 4 | export class View { 5 | @PrimaryGeneratedColumn("uuid") 6 | id!: string; 7 | 8 | @Column({type: String, transformer: []}) 9 | title!: string; 10 | } 11 | -------------------------------------------------------------------------------- /sample/sample26-embedded-tables/entity/Counters.ts: -------------------------------------------------------------------------------- 1 | import {Column} from "../../../src/index"; 2 | 3 | export class Counters { 4 | 5 | @Column() 6 | raiting: number; 7 | 8 | @Column() 9 | stars: number; 10 | 11 | @Column() 12 | commentCount: number; 13 | 14 | @Column() 15 | metadata: string; 16 | 17 | } -------------------------------------------------------------------------------- /sample/sample3-many-to-one/entity/PostCategory.ts: -------------------------------------------------------------------------------- 1 | import {Column, Entity, PrimaryGeneratedColumn} from "../../../src/index.ts"; 2 | 3 | @Entity("sample3_post_category") 4 | export class PostCategory { 5 | 6 | @PrimaryGeneratedColumn() 7 | id: number; 8 | 9 | @Column({ type: String }) 10 | name: string; 11 | 12 | } 13 | -------------------------------------------------------------------------------- /sample/sample33-custom-repository/entity/Author.ts: -------------------------------------------------------------------------------- 1 | import {Column, Entity, PrimaryGeneratedColumn} from "../../../src/index"; 2 | 3 | @Entity() 4 | export class Author { 5 | 6 | @PrimaryGeneratedColumn() 7 | id: number; 8 | 9 | @Column() 10 | firstName: string; 11 | 12 | @Column() 13 | lastName: string; 14 | 15 | } -------------------------------------------------------------------------------- /sample/sample33-custom-repository/entity/User.ts: -------------------------------------------------------------------------------- 1 | import {Column, Entity, PrimaryGeneratedColumn} from "../../../src/index"; 2 | 3 | @Entity() 4 | export class User { 5 | 6 | @PrimaryGeneratedColumn() 7 | id: number; 8 | 9 | @Column() 10 | firstName: string; 11 | 12 | @Column() 13 | lastName: string; 14 | 15 | } -------------------------------------------------------------------------------- /sample/sample4-many-to-many/entity/PostCategory.ts: -------------------------------------------------------------------------------- 1 | import {Column, Entity, PrimaryGeneratedColumn} from "../../../src/index.ts"; 2 | 3 | @Entity("sample4_post_category") 4 | export class PostCategory { 5 | 6 | @PrimaryGeneratedColumn() 7 | id: number; 8 | 9 | @Column({ type: String }) 10 | name: string; 11 | 12 | } 13 | -------------------------------------------------------------------------------- /src/util/fs.ts: -------------------------------------------------------------------------------- 1 | export { ensureDir } from "../../vendor/https/deno.land/std/fs/ensure_dir.ts"; 2 | export { expandGlob } from "../../vendor/https/deno.land/std/fs/expand_glob.ts"; 3 | export { exists, existsSync } from "../../vendor/https/deno.land/std/fs/exists.ts"; 4 | export { emptyDir } from "../../vendor/https/deno.land/std/fs/empty_dir.ts"; 5 | -------------------------------------------------------------------------------- /test/github-issues/56/entity/AccessToken.ts: -------------------------------------------------------------------------------- 1 | import {PrimaryColumn} from "../../../../src/decorator/columns/PrimaryColumn.ts"; 2 | import {Entity} from "../../../../src/decorator/entity/Entity.ts"; 3 | 4 | @Entity() 5 | export class AccessToken { 6 | 7 | @PrimaryColumn({ type: String }) 8 | access_token!: string; 9 | 10 | } 11 | -------------------------------------------------------------------------------- /src/decorator/options/ColumnEmbeddedOptions.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Column options specific to embedded column. 3 | */ 4 | export interface ColumnEmbeddedOptions { 5 | 6 | /** 7 | * Embedded column prefix. 8 | * If set to empty string or false, then prefix is not set at all. 9 | */ 10 | prefix?: string | boolean; 11 | 12 | } 13 | -------------------------------------------------------------------------------- /src/find-options/operator/Between.ts: -------------------------------------------------------------------------------- 1 | import {FindOperator} from "../FindOperator.ts"; 2 | 3 | /** 4 | * Find Options Operator. 5 | * Example: { someField: Between(x, y) } 6 | */ 7 | export function Between(from: T|FindOperator, to: T|FindOperator) { 8 | return new FindOperator("between", [from, to] as any, true, true); 9 | } 10 | -------------------------------------------------------------------------------- /test/github-issues/1326/entity/SpecificUser.ts: -------------------------------------------------------------------------------- 1 | import {Column, Entity, PrimaryGeneratedColumn} from "../../../../src/index.ts"; 2 | 3 | @Entity("user", { database: "db_2" }) 4 | export class SpecificUser { 5 | 6 | @PrimaryGeneratedColumn() 7 | id!: number; 8 | 9 | @Column({ type: String }) 10 | name!: string; 11 | 12 | } 13 | -------------------------------------------------------------------------------- /test/github-issues/1751/entity/User.ts: -------------------------------------------------------------------------------- 1 | import {Column, Entity, PrimaryGeneratedColumn} from "../../../../src/index.ts"; 2 | 3 | @Entity() 4 | export class User { 5 | 6 | @PrimaryGeneratedColumn() 7 | id = undefined; 8 | 9 | @Column("varchar") 10 | email = ""; 11 | 12 | @Column("varchar") 13 | avatarURL = ""; 14 | } 15 | -------------------------------------------------------------------------------- /test/github-issues/2693/entity/user.ts: -------------------------------------------------------------------------------- 1 | import {PrimaryGeneratedColumn} from "../../../../src/decorator/columns/PrimaryGeneratedColumn.ts"; 2 | import {Entity} from "../../../../src/decorator/entity/Entity.ts"; 3 | 4 | @Entity({name: "users", synchronize: false}) 5 | export class User { 6 | @PrimaryGeneratedColumn("uuid") 7 | id!: number; 8 | } 9 | -------------------------------------------------------------------------------- /test/github-issues/4719/entity/Post.ts: -------------------------------------------------------------------------------- 1 | import {Column, Entity, PrimaryGeneratedColumn, ObjectLiteral} from "../../../../src/index.ts"; 2 | 3 | @Entity() 4 | export class Post { 5 | 6 | @PrimaryGeneratedColumn() 7 | id!: number; 8 | 9 | @Column("hstore", { hstoreType: "object" }) 10 | hstoreObj!: ObjectLiteral; 11 | 12 | } 13 | -------------------------------------------------------------------------------- /test/github-issues/762/entity/FooChildMetadata.ts: -------------------------------------------------------------------------------- 1 | import {Column} from "../../../../src/decorator/columns/Column.ts"; 2 | 3 | export class FooChildMetadata { 4 | 5 | @Column({ nullable: true, type: Number }) 6 | something!: number; 7 | 8 | @Column({ nullable: true, type: Number }) 9 | somethingElse!: number; 10 | 11 | } 12 | -------------------------------------------------------------------------------- /test/other-issues/inheritance-duplicate-columns/entity/BasePost.ts: -------------------------------------------------------------------------------- 1 | import {PrimaryGeneratedColumn} from "../../../../src/decorator/columns/PrimaryGeneratedColumn.ts"; 2 | import {BaseContent} from "./BaseContent.ts"; 3 | 4 | export class BasePost extends BaseContent { 5 | 6 | @PrimaryGeneratedColumn() 7 | id!: number; 8 | 9 | } 10 | -------------------------------------------------------------------------------- /src/decorator/options/ColumnEnumOptions.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Column options for enum-typed columns. 3 | */ 4 | export interface ColumnEnumOptions { 5 | 6 | /** 7 | * Array of possible enumerated values. 8 | */ 9 | enum?: any[]|Object; 10 | /** 11 | * Exact name of enum 12 | */ 13 | enumName?: string; 14 | 15 | } 16 | -------------------------------------------------------------------------------- /test/functional/table-inheritance/single-table/database-option-inherited/entity/Employee.ts: -------------------------------------------------------------------------------- 1 | import {ChildEntity, Column} from "../../../../../../src/index.ts"; 2 | 3 | import {Person} from "./Person.ts"; 4 | 5 | @ChildEntity() 6 | export class Employee extends Person { 7 | 8 | @Column({ type: Number }) 9 | salary!: number; 10 | 11 | } 12 | -------------------------------------------------------------------------------- /test/functional/uuid/cockroach/entity/Record.ts: -------------------------------------------------------------------------------- 1 | import {Entity} from "../../../../../src/decorator/entity/Entity.ts"; 2 | import {PrimaryGeneratedColumn} from "../../../../../src/decorator/columns/PrimaryGeneratedColumn.ts"; 3 | 4 | @Entity() 5 | export class Record { 6 | 7 | @PrimaryGeneratedColumn("uuid") 8 | id!: string; 9 | 10 | } 11 | -------------------------------------------------------------------------------- /test/functional/uuid/postgres/entity/Record.ts: -------------------------------------------------------------------------------- 1 | import {Entity} from "../../../../../src/decorator/entity/Entity.ts"; 2 | import {PrimaryGeneratedColumn} from "../../../../../src/decorator/columns/PrimaryGeneratedColumn.ts"; 3 | 4 | @Entity() 5 | export class Record { 6 | 7 | @PrimaryGeneratedColumn("uuid") 8 | id!: string; 9 | 10 | } 11 | -------------------------------------------------------------------------------- /test/github-issues/4513/entity/User.ts: -------------------------------------------------------------------------------- 1 | import { Entity, PrimaryColumn, Column } from "../../../../src/index.ts"; 2 | 3 | @Entity() 4 | export class User { 5 | @PrimaryColumn({ type: String }) 6 | name!: string; 7 | 8 | @PrimaryColumn({ type: String }) 9 | email!: string; 10 | 11 | @Column({ type: Number }) 12 | age!: number; 13 | } 14 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "3.8.3", 3 | "compilerOptions": { 4 | "strict": true, 5 | "target": "esnext", 6 | "experimentalDecorators": true, 7 | "sourceMap": true 8 | }, 9 | "exclude": [ 10 | "tmp", 11 | "temp", 12 | "build", 13 | "node_modules" 14 | ] 15 | } 16 | -------------------------------------------------------------------------------- /sample/sample28-single-table-inheritance/entity/Employee.ts: -------------------------------------------------------------------------------- 1 | import {Column} from "../../../src/decorator/columns/Column"; 2 | import {Person} from "./Person"; 3 | import {ChildEntity} from "../../../src/decorator/entity/ChildEntity"; 4 | 5 | @ChildEntity() 6 | export class Employee extends Person { 7 | 8 | @Column() 9 | salary: number; 10 | 11 | } -------------------------------------------------------------------------------- /sample/sample28-single-table-inheritance/entity/Student.ts: -------------------------------------------------------------------------------- 1 | import {Column} from "../../../src/decorator/columns/Column"; 2 | import {Person} from "./Person"; 3 | import {ChildEntity} from "../../../src/decorator/entity/ChildEntity"; 4 | 5 | @ChildEntity() 6 | export class Student extends Person { 7 | 8 | @Column() 9 | faculty: string; 10 | 11 | } -------------------------------------------------------------------------------- /sample/sample31-table-prefix/entity/Author.ts: -------------------------------------------------------------------------------- 1 | import {Column, Entity, PrimaryGeneratedColumn} from "../../../src/index"; 2 | 3 | @Entity("sample31_author") 4 | export class Author { 5 | 6 | @PrimaryGeneratedColumn() 7 | id: number; 8 | 9 | @Column() 10 | firstName: string; 11 | 12 | @Column() 13 | lastName: string; 14 | 15 | } -------------------------------------------------------------------------------- /test/github-issues/4096/entity/User.ts: -------------------------------------------------------------------------------- 1 | import { Entity, PrimaryColumn, Column } from "../../../../src/index.ts"; 2 | 3 | @Entity() 4 | export class User { 5 | @PrimaryColumn({ type: String }) 6 | email!: string; 7 | 8 | @PrimaryColumn({ type: String }) 9 | username!: string; 10 | 11 | @Column({ type: String }) 12 | bio!: string; 13 | } 14 | -------------------------------------------------------------------------------- /src/error/NotImplementedError.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Thrown when user tries to call unimplemented method. 3 | */ 4 | export class NotImplementedError extends Error { 5 | name = "NotImplementedError"; 6 | 7 | constructor(functionName: string) { 8 | super(); 9 | this.message = `\`${functionName}\` is not supported`; 10 | } 11 | 12 | } 13 | -------------------------------------------------------------------------------- /src/entity-schema/EntitySchema.ts: -------------------------------------------------------------------------------- 1 | import {EntitySchemaOptions} from "./EntitySchemaOptions.ts"; 2 | 3 | /** 4 | * Interface for entity metadata mappings stored inside "schemas" instead of models decorated by decorators. 5 | */ 6 | export class EntitySchema { 7 | 8 | constructor(public options: EntitySchemaOptions) { 9 | } 10 | 11 | } 12 | -------------------------------------------------------------------------------- /src/find-options/FindOperatorType.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * List of types that FindOperator can be. 3 | */ 4 | export type FindOperatorType = "not" 5 | | "lessThan" 6 | | "lessThanOrEqual" 7 | | "moreThan" 8 | | "moreThanOrEqual" 9 | | "equal" 10 | | "between" 11 | | "in" 12 | | "any" 13 | | "isNull" 14 | | "like" 15 | | "raw"; 16 | -------------------------------------------------------------------------------- /test/github-issues/1369/entity/AbstractEntity.ts: -------------------------------------------------------------------------------- 1 | import {Column, PrimaryGeneratedColumn} from "../../../../src/index.ts"; 2 | 3 | export abstract class AbstractEntity { 4 | @PrimaryGeneratedColumn() id!: number; 5 | @Column({ type: String }) firstname!: string; 6 | @Column({ type: String }) lastname!: string; 7 | @Column({ type: String }) fullname!: string; 8 | } 9 | -------------------------------------------------------------------------------- /test/github-issues/1591/entity/Photo.ts: -------------------------------------------------------------------------------- 1 | import {Column, Entity, PrimaryGeneratedColumn} from "../../../../src/index.ts"; 2 | 3 | @Entity() 4 | export class Photo { 5 | 6 | @PrimaryGeneratedColumn() 7 | id!: number; 8 | 9 | @Column({ type: String }) 10 | name!: string; 11 | 12 | @Column({ type: Date }) 13 | date!: Date; 14 | 15 | } 16 | -------------------------------------------------------------------------------- /test/github-issues/204/entity/RecordData.ts: -------------------------------------------------------------------------------- 1 | export class RecordData { 2 | 3 | constructor(public data1: string, 4 | public data2: string, 5 | public data3: string, 6 | public data4: string, 7 | public isActive: boolean, 8 | public isReadonly: boolean) { 9 | } 10 | 11 | } 12 | -------------------------------------------------------------------------------- /test/github-issues/720/entity/Message.ts: -------------------------------------------------------------------------------- 1 | import {PrimaryGeneratedColumn} from "../../../../src/decorator/columns/PrimaryGeneratedColumn.ts"; 2 | import {Entity} from "../../../../src/decorator/entity/Entity.ts"; 3 | 4 | @Entity() 5 | export class Message { 6 | 7 | @PrimaryGeneratedColumn("increment", { type: "bigint" }) 8 | id!: string; 9 | 10 | } 11 | -------------------------------------------------------------------------------- /test/github-issues/1042/entity/Information.ts: -------------------------------------------------------------------------------- 1 | import {Column} from "../../../../src/decorator/columns/Column.ts"; 2 | 3 | export class Information { 4 | 5 | @Column({ type: String }) 6 | maritalStatus!: string; 7 | 8 | @Column({ type: String }) 9 | gender!: string; 10 | 11 | @Column({ type: String }) 12 | address!: string; 13 | 14 | } 15 | -------------------------------------------------------------------------------- /test/github-issues/2499/entity/Foo.ts: -------------------------------------------------------------------------------- 1 | import {Column, PrimaryGeneratedColumn} from "../../../../src/index.ts"; 2 | import {Entity} from "../../../../src/decorator/entity/Entity.ts"; 3 | 4 | @Entity("foo") 5 | export class Foo { 6 | 7 | @PrimaryGeneratedColumn() 8 | id!: number; 9 | 10 | @Column({ type: String }) 11 | description!: string; 12 | } 13 | -------------------------------------------------------------------------------- /docs/zh_CN/delete-query-builder.md: -------------------------------------------------------------------------------- 1 | # 使用 Query Builder 删除 2 | 3 | 你可以使用`QueryBuilder`创建`DELETE`查询。 4 | 例如: 5 | 6 | ```typescript 7 | import { getConnection } from "typeorm"; 8 | 9 | await getConnection() 10 | .createQueryBuilder() 11 | .delete() 12 | .from(User) 13 | .where("id = :id", { id: 1 }) 14 | .execute(); 15 | ``` 16 | 17 | 就性能而言,这是删除数据库中的实体的最有效方法。 18 | -------------------------------------------------------------------------------- /src/find-options/operator/Not.ts: -------------------------------------------------------------------------------- 1 | import {FindOperator} from "../FindOperator.ts"; 2 | 3 | /** 4 | * Find Options Operator. 5 | * Used to negotiate expression. 6 | * Example: { title: not("hello") } will return entities where title not equal to "hello". 7 | */ 8 | export function Not(value: T|FindOperator) { 9 | return new FindOperator("not", value); 10 | } 11 | -------------------------------------------------------------------------------- /test/functional/decorators/embedded/entity/Counters.ts: -------------------------------------------------------------------------------- 1 | import {Column} from "../../../../../src/decorator/columns/Column.ts"; 2 | 3 | export class Counters { 4 | 5 | @Column({ type: Number }) 6 | likes!: number; 7 | 8 | @Column({ type: Number }) 9 | comments!: number; 10 | 11 | @Column({ type: Number }) 12 | favorites!: number; 13 | 14 | } 15 | -------------------------------------------------------------------------------- /test/github-issues/131/entity/Employee.ts: -------------------------------------------------------------------------------- 1 | import {Column} from "../../../../src/decorator/columns/Column.ts"; 2 | import {Person} from "./Person.ts"; 3 | import {ChildEntity} from "../../../../src/decorator/entity/ChildEntity.ts"; 4 | 5 | @ChildEntity() 6 | export class Employee extends Person { 7 | 8 | @Column({ type: Number }) 9 | salary!: number; 10 | 11 | } 12 | -------------------------------------------------------------------------------- /test/github-issues/131/entity/Student.ts: -------------------------------------------------------------------------------- 1 | import {Column} from "../../../../src/decorator/columns/Column.ts"; 2 | import {Person} from "./Person.ts"; 3 | import {ChildEntity} from "../../../../src/decorator/entity/ChildEntity.ts"; 4 | 5 | @ChildEntity() 6 | export class Student extends Person { 7 | 8 | @Column({ type: String }) 9 | faculty!: string; 10 | 11 | } 12 | -------------------------------------------------------------------------------- /test/github-issues/1576/entity/Category.ts: -------------------------------------------------------------------------------- 1 | import {Column, PrimaryGeneratedColumn, Entity} from "../../../../src/index.ts"; 2 | 3 | @Entity() 4 | export class Category { 5 | 6 | @PrimaryGeneratedColumn() 7 | id!: number; 8 | 9 | @Column({ type: String }) 10 | name!: string; 11 | 12 | @Column({ type: String }) 13 | name2!: string; 14 | 15 | } 16 | -------------------------------------------------------------------------------- /test/github-issues/2103/entity/Complex.ts: -------------------------------------------------------------------------------- 1 | import {Entity, Column, PrimaryColumn} from "../../../../src/index.ts"; 2 | 3 | @Entity() 4 | export class Complex { 5 | 6 | @PrimaryColumn({ type: Number }) 7 | id!: number; 8 | 9 | @PrimaryColumn({ type: Number }) 10 | code!: number; 11 | 12 | @Column({ type: Number }) 13 | x!: number; 14 | 15 | } 16 | -------------------------------------------------------------------------------- /test/github-issues/2199/entity/Bar.ts: -------------------------------------------------------------------------------- 1 | import { Column, PrimaryGeneratedColumn } from "../../../../src/index.ts"; 2 | import { Entity } from "../../../../src/decorator/entity/Entity.ts"; 3 | 4 | @Entity("bar") 5 | export class Bar { 6 | 7 | @PrimaryGeneratedColumn() 8 | id!: number; 9 | 10 | @Column({ type: String }) 11 | description!: string; 12 | } 13 | -------------------------------------------------------------------------------- /test/github-issues/4190/entity/Profile.ts: -------------------------------------------------------------------------------- 1 | import {Entity, PrimaryGeneratedColumn, Column} from "../../../../src/index.ts"; 2 | 3 | @Entity() 4 | export class Profile { 5 | 6 | @PrimaryGeneratedColumn() 7 | id!: number; 8 | 9 | @Column({ type: String }) 10 | gender!: string; 11 | 12 | @Column({ type: String }) 13 | photo!: string; 14 | 15 | } 16 | -------------------------------------------------------------------------------- /test/github-issues/5004/entity/Foo.ts: -------------------------------------------------------------------------------- 1 | import {Column} from "../../../../src/decorator/columns/Column.ts"; 2 | import {Entity} from "../../../../src/decorator/entity/Entity.ts"; 3 | import {Index} from "../../../../src/decorator/Index.ts"; 4 | 5 | @Entity() 6 | export class Foo { 7 | @Column("date") 8 | @Index({ expireAfterSeconds: 0 }) 9 | expireAt!: Date; 10 | } 11 | -------------------------------------------------------------------------------- /sample/sample28-single-table-inheritance/entity/Homesitter.ts: -------------------------------------------------------------------------------- 1 | import {Column} from "../../../src/decorator/columns/Column"; 2 | import {Person} from "./Person"; 3 | import {ChildEntity} from "../../../src/decorator/entity/ChildEntity"; 4 | 5 | @ChildEntity("home-sitter") 6 | export class Homesitter extends Person { 7 | 8 | @Column() 9 | numberOfKids: number; 10 | 11 | } -------------------------------------------------------------------------------- /src/metadata-args/NamingStrategyMetadataArgs.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Arguments for NamingStrategyMetadata class. 3 | */ 4 | export interface NamingStrategyMetadataArgs { 5 | 6 | /** 7 | * Class to which this column is applied. 8 | */ 9 | readonly target: Function; 10 | 11 | /** 12 | * Strategy name. 13 | */ 14 | readonly name: string; 15 | 16 | } 17 | -------------------------------------------------------------------------------- /test/functional/embedded/basic-functionality/entity/Counters.ts: -------------------------------------------------------------------------------- 1 | import {Column} from "../../../../../src/decorator/columns/Column.ts"; 2 | 3 | export class Counters { 4 | 5 | @Column({ type: Number }) 6 | likes!: number; 7 | 8 | @Column({ type: Number }) 9 | comments!: number; 10 | 11 | @Column({ type: Number }) 12 | favorites!: number; 13 | 14 | } 15 | -------------------------------------------------------------------------------- /test/functional/table-inheritance/extending/entity/Post.ts: -------------------------------------------------------------------------------- 1 | import {Entity} from "../../../../../src/decorator/entity/Entity.ts"; 2 | import {Column} from "../../../../../src/decorator/columns/Column.ts"; 3 | import {Content} from "./Content.ts"; 4 | 5 | @Entity() 6 | export class Post extends Content { 7 | 8 | @Column({ type: String }) 9 | text!: string; 10 | 11 | } 12 | -------------------------------------------------------------------------------- /test/github-issues/1733/entity/Post.ts: -------------------------------------------------------------------------------- 1 | import {Column, Entity, PrimaryGeneratedColumn} from "../../../../src/index.ts"; 2 | 3 | @Entity() 4 | export class Post { 5 | 6 | @PrimaryGeneratedColumn() 7 | id!: number; 8 | 9 | @Column({ type: String }) 10 | name!: string; 11 | 12 | @Column({ type: String, length: 255 }) 13 | name2!: string; 14 | 15 | } 16 | -------------------------------------------------------------------------------- /test/github-issues/609/entity/Post.ts: -------------------------------------------------------------------------------- 1 | import {CreateDateColumn, Entity, PrimaryGeneratedColumn} from "../../../../src/index.ts"; 2 | 3 | @Entity() 4 | export class Post { 5 | 6 | @PrimaryGeneratedColumn() 7 | id!: number; 8 | 9 | @CreateDateColumn({ precision: null, type: "timestamp", default: () => "CURRENT_TIMESTAMP" }) 10 | createDate!: Date; 11 | 12 | } 13 | -------------------------------------------------------------------------------- /src/common/DeepPartial.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Same as Partial but goes deeper and makes Partial all its properties and sub-properties. 3 | */ 4 | export type DeepPartial = { 5 | [P in keyof T]?: 6 | T[P] extends Array ? Array> : 7 | T[P] extends ReadonlyArray ? ReadonlyArray> : 8 | DeepPartial 9 | }; 10 | -------------------------------------------------------------------------------- /test/functional/connection/modules/blog/schema/blog-category.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "BlogCategory", 3 | "table": { 4 | "name": "blog_category" 5 | }, 6 | "columns": { 7 | "id": { 8 | "type": "int", 9 | "primary": true, 10 | "generated": true 11 | }, 12 | "name": { 13 | "type": "varchar", 14 | "nullable": false 15 | } 16 | } 17 | } -------------------------------------------------------------------------------- /test/functional/persistence/partial-persist/entity/Counters.ts: -------------------------------------------------------------------------------- 1 | import {Column} from "../../../../../src/decorator/columns/Column.ts"; 2 | 3 | export class Counters { 4 | 5 | @Column({ type: Number }) 6 | stars!: number; 7 | 8 | @Column({ type: Number }) 9 | commentCount!: number; 10 | 11 | @Column({ type: String }) 12 | metadata!: string; 13 | 14 | } 15 | -------------------------------------------------------------------------------- /test/functional/relations/relation-mapped-to-different-name-column/entity/PostDetails.ts: -------------------------------------------------------------------------------- 1 | import {Entity} from "../../../../../src/decorator/entity/Entity.ts"; 2 | import {PrimaryColumn} from "../../../../../src/decorator/columns/PrimaryColumn.ts"; 3 | 4 | @Entity() 5 | export class PostDetails { 6 | 7 | @PrimaryColumn({ type: String }) 8 | keyword!: string; 9 | 10 | } 11 | -------------------------------------------------------------------------------- /test/github-issues/1685/entity/year.ts: -------------------------------------------------------------------------------- 1 | import {PrimaryColumn, Entity, OneToMany} from "../../../../src/index.ts"; 2 | import {Month} from "./month.ts"; 3 | 4 | @Entity() 5 | export class Year { 6 | 7 | @PrimaryColumn({ type: Number }) 8 | public yearNo!: number; 9 | 10 | @OneToMany(type => Month, month => month.yearNo) 11 | public month!: Month[]; 12 | 13 | } 14 | -------------------------------------------------------------------------------- /test/github-issues/2200/entity/Contact.ts: -------------------------------------------------------------------------------- 1 | import {Entity, PrimaryGeneratedColumn, OneToMany} from "../../../../src/index.ts"; 2 | import { Booking } from "./Booking.ts"; 3 | 4 | @Entity() 5 | export class Contact { 6 | 7 | @PrimaryGeneratedColumn() 8 | id!: number; 9 | 10 | @OneToMany(type => Booking, booking => booking.contact) 11 | bookings!: Booking[]; 12 | } 13 | -------------------------------------------------------------------------------- /test/github-issues/4220/entity/User.ts: -------------------------------------------------------------------------------- 1 | import {Entity, PrimaryColumn, Column} from "../../../../src/index.ts"; 2 | 3 | @Entity() 4 | export class User { 5 | @PrimaryColumn({ 6 | comment: "The ID of this user.", 7 | length: 16, 8 | type: "binary", 9 | }) 10 | id!: Uint8Array; 11 | 12 | @Column({ type: String }) 13 | name!: string; 14 | } 15 | -------------------------------------------------------------------------------- /test/github-issues/762/entity/FooMetadata.ts: -------------------------------------------------------------------------------- 1 | import {Column} from "../../../../src/decorator/columns/Column.ts"; 2 | import {FooChildMetadata} from "./FooChildMetadata.ts"; 3 | 4 | export class FooMetadata { 5 | 6 | @Column({ type: Number, nullable: true }) 7 | bar!: number; 8 | 9 | @Column(type => FooChildMetadata) 10 | child?: FooChildMetadata; 11 | 12 | } 13 | -------------------------------------------------------------------------------- /sample/sample30-default-order-by/entity/Category.ts: -------------------------------------------------------------------------------- 1 | import {Column, Entity, PrimaryGeneratedColumn} from "../../../src/index"; 2 | 3 | @Entity("sample30_category") 4 | export class Category { 5 | 6 | @PrimaryGeneratedColumn() 7 | id: number; 8 | 9 | @Column() 10 | name: string; 11 | 12 | constructor(name: string) { 13 | this.name = name; 14 | } 15 | 16 | } -------------------------------------------------------------------------------- /src/error/EntityColumnNotFound.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | export class EntityColumnNotFound extends Error { 5 | name = "EntityColumnNotFound"; 6 | 7 | constructor(propertyPath: string) { 8 | super(); 9 | Object.setPrototypeOf(this, EntityColumnNotFound.prototype); 10 | this.message = `No entity column "${propertyPath}" was found.`; 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /test/functional/connection/modules/video/schema/video-category.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "VideoCategory", 3 | "table": { 4 | "name": "video_category" 5 | }, 6 | "columns": { 7 | "id": { 8 | "type": "int", 9 | "primary": true, 10 | "generated": true 11 | }, 12 | "name": { 13 | "type": "varchar", 14 | "nullable": false 15 | } 16 | } 17 | } -------------------------------------------------------------------------------- /test/github-issues/2128/entity/Post.ts: -------------------------------------------------------------------------------- 1 | import { PrimaryGeneratedColumn, Entity, Column } from "../../../../src/index.ts"; 2 | 3 | @Entity() 4 | export class Post { 5 | 6 | @PrimaryGeneratedColumn() 7 | id!: number; 8 | 9 | @Column({ type: String }) 10 | title!: string; 11 | 12 | @Column({ 13 | type: "json" 14 | }) 15 | meta!: any; 16 | 17 | } 18 | -------------------------------------------------------------------------------- /test/github-issues/3702/entity/LetterBox.ts: -------------------------------------------------------------------------------- 1 | import {Entity, PrimaryGeneratedColumn} from "../../../../src/index.ts"; 2 | import {Column} from "../../../../src/decorator/columns/Column.ts"; 3 | 4 | @Entity() 5 | export class LetterBox { 6 | 7 | @PrimaryGeneratedColumn() 8 | id!: number; 9 | 10 | @Column({ type: "point", srid: 4326 }) 11 | coord!: string; 12 | 13 | } 14 | -------------------------------------------------------------------------------- /src/find-options/OrderByCondition.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Special object that defines order condition for ORDER BY in sql. 3 | * 4 | * Example: 5 | * { 6 | * "name": "ASC", 7 | * "id": "DESC" 8 | * } 9 | */ 10 | export type OrderByCondition = { 11 | [columnName: string]: ("ASC"|"DESC")|{ 12 | order: "ASC"|"DESC"; 13 | nulls?: "NULLS FIRST"|"NULLS LAST"; 14 | } 15 | }; 16 | -------------------------------------------------------------------------------- /src/metadata-args/DiscriminatorValueMetadataArgs.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * DiscriminatorValue properties. 3 | */ 4 | export interface DiscriminatorValueMetadataArgs { 5 | 6 | /** 7 | * Class to which discriminator name is applied. 8 | */ 9 | readonly target: Function|string; 10 | 11 | /** 12 | * Discriminator value. 13 | */ 14 | readonly value: any; 15 | 16 | } 17 | -------------------------------------------------------------------------------- /test/github-issues/1997/entity/Post.ts: -------------------------------------------------------------------------------- 1 | import { Column, Entity, PrimaryGeneratedColumn } from "../../../../src/index.ts"; 2 | 3 | @Entity({schema: "schema"}) 4 | export class Post { 5 | 6 | @PrimaryGeneratedColumn() 7 | id!: number; 8 | 9 | @Column("enum", { enum: ["A", "B", "C"] }) 10 | enum!: string; 11 | 12 | @Column({ type: String }) 13 | name!: string; 14 | } 15 | -------------------------------------------------------------------------------- /sample/sample24-schemas/entity/Post.ts: -------------------------------------------------------------------------------- 1 | import {Image} from "./Image"; 2 | import {Category} from "./Category"; 3 | import {PostDetails} from "./PostDetails"; 4 | 5 | export interface Post { 6 | 7 | id?: number; 8 | title: string; 9 | text: string; 10 | details?: PostDetails; 11 | images?: Image[]; 12 | secondaryImages?: Image[]; 13 | categories?: Category[]; 14 | 15 | } -------------------------------------------------------------------------------- /test/functional/connection/modules/question/schema/question-category.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "QuestionCategory", 3 | "table": { 4 | "name": "question_category" 5 | }, 6 | "columns": { 7 | "id": { 8 | "type": "int", 9 | "primary": true, 10 | "generated": true 11 | }, 12 | "name": { 13 | "type": "varchar", 14 | "nullable": false 15 | } 16 | } 17 | } -------------------------------------------------------------------------------- /test/functional/mongodb/basic/embedded-columns/entity/Information.ts: -------------------------------------------------------------------------------- 1 | import {Column} from "../../../../../../src/decorator/columns/Column.ts"; 2 | 3 | export class Information { 4 | 5 | @Column({ type: String }) 6 | description!: string; 7 | 8 | @Column({ type: Boolean }) 9 | visible!: boolean; 10 | 11 | @Column({ type: Boolean }) 12 | editable!: boolean; 13 | 14 | } 15 | -------------------------------------------------------------------------------- /test/github-issues/2287/entity/Post.ts: -------------------------------------------------------------------------------- 1 | import {Entity, PrimaryGeneratedColumn} from "../../../../src/index.ts"; 2 | import {Column} from "../../../../src/decorator/columns/Column.ts"; 3 | 4 | @Entity() 5 | export class Post { 6 | 7 | @PrimaryGeneratedColumn() 8 | id!: number; 9 | 10 | @Column("int", { array: true, nullable: true}) 11 | skill_id_array!: number[]; 12 | 13 | } 14 | -------------------------------------------------------------------------------- /sample/sample12-custom-naming-strategy/entity/Post.ts: -------------------------------------------------------------------------------- 1 | import {Column, Entity, PrimaryGeneratedColumn} from "../../../src/index"; 2 | 3 | @Entity("sample1_post") 4 | export class Post { 5 | 6 | @PrimaryGeneratedColumn() 7 | id: number; 8 | 9 | @Column() 10 | title: string; 11 | 12 | @Column() 13 | text: string; 14 | 15 | @Column() 16 | likesCount: number; 17 | 18 | } -------------------------------------------------------------------------------- /src/decorator/options/ColumnWithLengthOptions.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Options for columns that can define a length of the column type. 3 | */ 4 | export interface ColumnWithLengthOptions { 5 | 6 | /** 7 | * Column type's length. 8 | * For example type = "varchar" and length = "100" means ORM will create a column with type varchar(100). 9 | */ 10 | length?: string|number; 11 | 12 | } 13 | -------------------------------------------------------------------------------- /src/driver/types/DatabaseType.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Database type. 3 | */ 4 | export type DatabaseType = 5 | "mysql"| 6 | "postgres"| 7 | "cockroachdb"| 8 | "sap"| 9 | "mariadb"| 10 | "sqlite"| 11 | "cordova"| 12 | "react-native"| 13 | "nativescript" | 14 | "sqljs"| 15 | "oracle"| 16 | "mssql"| 17 | "mongodb"| 18 | "aurora-data-api"| 19 | "expo"; 20 | -------------------------------------------------------------------------------- /src/query-builder/result/DeleteResult.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Result object returned by DeleteQueryBuilder execution. 3 | */ 4 | export class DeleteResult { 5 | /** 6 | * Raw SQL result returned by executed query. 7 | */ 8 | raw: any; 9 | 10 | /** 11 | * Number of affected rows/documents 12 | * Not all drivers support this 13 | */ 14 | affected?: number|null; 15 | } 16 | -------------------------------------------------------------------------------- /test/github-issues/2779/entity/Post.ts: -------------------------------------------------------------------------------- 1 | import { Column, Entity, PrimaryGeneratedColumn } from "../../../../src/index.ts"; 2 | import { Role } from "../set.ts"; 3 | 4 | @Entity("post") 5 | export class Post { 6 | 7 | @PrimaryGeneratedColumn() 8 | id!: number; 9 | 10 | @Column("set", { 11 | default: [Role.Admin, Role.Developer], 12 | enum: Role 13 | }) 14 | roles!: Role[]; 15 | } 16 | -------------------------------------------------------------------------------- /test/github-issues/3349/entity/Category.ts: -------------------------------------------------------------------------------- 1 | import {PrimaryColumn} from "../../../../src/index.ts"; 2 | import {Column} from "../../../../src/index.ts"; 3 | import {Entity} from "../../../../src/index.ts"; 4 | 5 | @Entity() 6 | export class Category { 7 | @PrimaryColumn({ type: Number }) 8 | public id!: number; 9 | 10 | @Column({ type: Number }) 11 | public myField!: number; 12 | } 13 | -------------------------------------------------------------------------------- /test/github-issues/3857/entity/Person.ts: -------------------------------------------------------------------------------- 1 | import {Entity, PrimaryGeneratedColumn, Column, TableInheritance} from "../../../../src/index.ts"; 2 | 3 | @Entity({schema: "custom"}) 4 | @TableInheritance({column: {type: "varchar", name: "type"}}) 5 | export abstract class Person { 6 | 7 | @PrimaryGeneratedColumn() 8 | id!: number; 9 | 10 | @Column("varchar") 11 | name!: string; 12 | } 13 | -------------------------------------------------------------------------------- /src/metadata-args/TreeMetadataArgs.ts: -------------------------------------------------------------------------------- 1 | import {TreeType} from "../metadata/types/TreeTypes.ts"; 2 | 3 | /** 4 | * Stores metadata collected for Tree entities. 5 | */ 6 | export interface TreeMetadataArgs { 7 | 8 | /** 9 | * Entity to which tree is applied. 10 | */ 11 | target: Function|string; 12 | 13 | /** 14 | * Tree type. 15 | */ 16 | type: TreeType; 17 | 18 | } 19 | -------------------------------------------------------------------------------- /test/functional/indices/embeddeds-index-test/entity/Profile.ts: -------------------------------------------------------------------------------- 1 | import {Column} from "../../../../../src/decorator/columns/Column.ts"; 2 | import {Index} from "../../../../../src/decorator/Index.ts"; 3 | 4 | export class Profile { 5 | 6 | @Column({ type: String }) 7 | job!: string; 8 | 9 | @Column({ type: String }) 10 | @Index("customer_profile_address") 11 | address!: string; 12 | } 13 | -------------------------------------------------------------------------------- /test/github-issues/1685/entity/user.ts: -------------------------------------------------------------------------------- 1 | import {PrimaryColumn, Entity, OneToMany} from "../../../../src/index.ts"; 2 | import {UserMonth} from "./user-month.ts"; 3 | 4 | @Entity() 5 | export class User { 6 | 7 | @PrimaryColumn({ type: String }) 8 | public username!: string; 9 | 10 | @OneToMany(type => UserMonth, userMonth => userMonth.user) 11 | public userMonths!: UserMonth[]; 12 | } 13 | -------------------------------------------------------------------------------- /test/github-issues/4630/entity/User.ts: -------------------------------------------------------------------------------- 1 | import { Entity, Column, PrimaryGeneratedColumn } from "../../../../src/index.ts"; 2 | 3 | export enum Realm { 4 | Blackrock = "Blackrock", 5 | KelThuzad = "Kel'Thuzad", 6 | } 7 | 8 | @Entity() 9 | export class User { 10 | @PrimaryGeneratedColumn() 11 | id!: number; 12 | 13 | @Column({ type: "enum", enum: Realm }) 14 | realm!: Realm; 15 | } 16 | -------------------------------------------------------------------------------- /test/github-issues/5174/entity/User.ts: -------------------------------------------------------------------------------- 1 | import {Entity} from "../../../../src/decorator/entity/Entity.ts"; 2 | import {PrimaryColumn, ManyToOne} from "../../../../src/index.ts"; 3 | import {Role} from "./Role.ts"; 4 | 5 | @Entity() 6 | export class User { 7 | 8 | @PrimaryColumn({ type: Number }) 9 | id!: number; 10 | 11 | @ManyToOne(_ => Role, role => role.users) 12 | role!: Role; 13 | 14 | } 15 | -------------------------------------------------------------------------------- /test/github-issues/922/entity/Post.ts: -------------------------------------------------------------------------------- 1 | import {Column, Entity, PrimaryGeneratedColumn} from "../../../../src/index.ts"; 2 | 3 | @Entity() 4 | export class Post { 5 | 6 | @PrimaryGeneratedColumn() 7 | id!: number; 8 | 9 | @Column("hstore", { hstoreType: "object" }) 10 | hstoreObj!: Object; 11 | 12 | @Column("hstore", { hstoreType: "string" }) 13 | hstoreStr!: string; 14 | 15 | } 16 | -------------------------------------------------------------------------------- /sample/sample10-mixed/entity/Cover.ts: -------------------------------------------------------------------------------- 1 | import {Column, Entity, OneToMany, PrimaryGeneratedColumn} from "../../../src/index"; 2 | import {Post} from "./Post"; 3 | 4 | @Entity("sample10_cover") 5 | export class Cover { 6 | 7 | @PrimaryGeneratedColumn() 8 | id: number; 9 | 10 | @Column() 11 | url: string; 12 | 13 | @OneToMany(type => Post, post => post.cover) 14 | posts: Post[]; 15 | 16 | } -------------------------------------------------------------------------------- /src/error/QueryRunnerAlreadyReleasedError.ts: -------------------------------------------------------------------------------- 1 | /** 2 | */ 3 | export class QueryRunnerAlreadyReleasedError extends Error { 4 | name = "QueryRunnerAlreadyReleasedError"; 5 | 6 | constructor() { 7 | super(); 8 | Object.setPrototypeOf(this, QueryRunnerAlreadyReleasedError.prototype); 9 | this.message = `Query runner already released. Cannot run queries anymore.`; 10 | } 11 | 12 | } -------------------------------------------------------------------------------- /test/functional/metadata-builder/metadata-args-storage/entity/Unit.ts: -------------------------------------------------------------------------------- 1 | import {PrimaryGeneratedColumn} from "../../../../../src/decorator/columns/PrimaryGeneratedColumn.ts"; 2 | import {Column} from "../../../../../src/decorator/columns/Column.ts"; 3 | 4 | export class Unit { 5 | 6 | @PrimaryGeneratedColumn() 7 | id!: string; 8 | 9 | @Column({ type: String }) 10 | type!: string; 11 | 12 | } 13 | -------------------------------------------------------------------------------- /test/functional/query-builder/delete/entity/Counters.ts: -------------------------------------------------------------------------------- 1 | import {Column} from "../../../../../src/decorator/columns/Column.ts"; 2 | 3 | export class Counters { 4 | 5 | @Column({ default: 1, type: Number }) 6 | likes!: number; 7 | 8 | @Column({ nullable: true, type: Number }) 9 | favorites!: number; 10 | 11 | @Column({ default: 0, type: Number }) 12 | comments!: number; 13 | 14 | } 15 | -------------------------------------------------------------------------------- /test/functional/query-builder/insert/entity/Counters.ts: -------------------------------------------------------------------------------- 1 | import {Column} from "../../../../../src/decorator/columns/Column.ts"; 2 | 3 | export class Counters { 4 | 5 | @Column({ default: 1, type: Number }) 6 | likes!: number; 7 | 8 | @Column({ nullable: true, type: Number }) 9 | favorites!: number; 10 | 11 | @Column({ default: 0, type: Number }) 12 | comments!: number; 13 | 14 | } 15 | -------------------------------------------------------------------------------- /test/functional/query-builder/update/entity/Counters.ts: -------------------------------------------------------------------------------- 1 | import {Column} from "../../../../../src/decorator/columns/Column.ts"; 2 | 3 | export class Counters { 4 | 5 | @Column({ default: 1, type: Number }) 6 | likes!: number; 7 | 8 | @Column({ nullable: true, type: Number }) 9 | favorites!: number; 10 | 11 | @Column({ default: 0, type: Number }) 12 | comments!: number; 13 | 14 | } 15 | -------------------------------------------------------------------------------- /test/functional/repository/find-options-operators/entity/Post.ts: -------------------------------------------------------------------------------- 1 | import {Column, Entity, PrimaryGeneratedColumn} from "../../../../../src/index.ts"; 2 | 3 | @Entity() 4 | export class Post { 5 | 6 | @PrimaryGeneratedColumn() 7 | id!: number; 8 | 9 | @Column({ nullable: true, type: String }) 10 | title!: string; 11 | 12 | @Column({ type: Number }) 13 | likes!: number; 14 | 15 | } 16 | -------------------------------------------------------------------------------- /test/github-issues/300/entity/Duration.ts: -------------------------------------------------------------------------------- 1 | import {Column} from "../../../../src/decorator/columns/Column.ts"; 2 | 3 | export class Duration { 4 | 5 | @Column({ type: Number, nullable: true }) 6 | minutes!: number|null; 7 | 8 | @Column({ type: Number, nullable: true }) 9 | hours!: number|null; 10 | 11 | @Column({ type: Number, nullable: true }) 12 | days!: number|null; 13 | 14 | } 15 | -------------------------------------------------------------------------------- /test/github-issues/4190/entity/Photo.ts: -------------------------------------------------------------------------------- 1 | import {Entity, PrimaryGeneratedColumn, Column, ManyToOne} from "../../../../src/index.ts"; 2 | import {User} from "./User.ts"; 3 | 4 | @Entity() 5 | export class Photo { 6 | 7 | @PrimaryGeneratedColumn() 8 | id!: number; 9 | 10 | @Column({ type: String }) 11 | url!: string; 12 | 13 | @ManyToOne("User", "photos") 14 | user!: User; 15 | 16 | } 17 | -------------------------------------------------------------------------------- /test/other-issues/hydrate-performance/entity/Post.ts: -------------------------------------------------------------------------------- 1 | import {Column, Entity, PrimaryGeneratedColumn} from "../../../../src/index.ts"; 2 | 3 | @Entity() 4 | export class Post { 5 | 6 | @PrimaryGeneratedColumn() 7 | id!: number; 8 | 9 | @Column({ type: String }) 10 | title!: string; 11 | 12 | constructor(title?: string) { 13 | if (title) this.title = title; 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /src/decorator/options/JoinColumnOptions.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Describes join column options. 3 | */ 4 | export interface JoinColumnOptions { 5 | 6 | /** 7 | * Name of the column. 8 | */ 9 | name?: string; 10 | 11 | /** 12 | * Name of the column in the entity to which this column is referenced. 13 | */ 14 | referencedColumnName?: string; // TODO rename to referencedColumn 15 | 16 | } 17 | -------------------------------------------------------------------------------- /test/functional/view-entity/general/entity/Category.ts: -------------------------------------------------------------------------------- 1 | import {Entity} from "../../../../../src/index.ts"; 2 | import {Column} from "../../../../../src/index.ts"; 3 | import {PrimaryGeneratedColumn} from "../../../../../src/index.ts"; 4 | 5 | @Entity() 6 | export class Category { 7 | 8 | @PrimaryGeneratedColumn() 9 | id!: number; 10 | 11 | @Column({ type: String }) 12 | name!: string; 13 | 14 | } 15 | -------------------------------------------------------------------------------- /test/functional/view-entity/mssql/entity/Category.ts: -------------------------------------------------------------------------------- 1 | import {Entity} from "../../../../../src/index.ts"; 2 | import {Column} from "../../../../../src/index.ts"; 3 | import {PrimaryGeneratedColumn} from "../../../../../src/index.ts"; 4 | 5 | @Entity() 6 | export class Category { 7 | 8 | @PrimaryGeneratedColumn() 9 | id!: number; 10 | 11 | @Column({ type: String }) 12 | name!: string; 13 | 14 | } 15 | -------------------------------------------------------------------------------- /test/functional/view-entity/mysql/entity/Category.ts: -------------------------------------------------------------------------------- 1 | import {Entity} from "../../../../../src/index.ts"; 2 | import {Column} from "../../../../../src/index.ts"; 3 | import {PrimaryGeneratedColumn} from "../../../../../src/index.ts"; 4 | 5 | @Entity() 6 | export class Category { 7 | 8 | @PrimaryGeneratedColumn() 9 | id!: number; 10 | 11 | @Column({ type: String }) 12 | name!: string; 13 | 14 | } 15 | -------------------------------------------------------------------------------- /test/functional/view-entity/oracle/entity/Category.ts: -------------------------------------------------------------------------------- 1 | import {Entity} from "../../../../../src/index.ts"; 2 | import {Column} from "../../../../../src/index.ts"; 3 | import {PrimaryGeneratedColumn} from "../../../../../src/index.ts"; 4 | 5 | @Entity() 6 | export class Category { 7 | 8 | @PrimaryGeneratedColumn() 9 | id!: number; 10 | 11 | @Column({ type: String }) 12 | name!: string; 13 | 14 | } 15 | -------------------------------------------------------------------------------- /test/functional/view-entity/sqlite/entity/Category.ts: -------------------------------------------------------------------------------- 1 | import {Entity} from "../../../../../src/index.ts"; 2 | import {Column} from "../../../../../src/index.ts"; 3 | import {PrimaryGeneratedColumn} from "../../../../../src/index.ts"; 4 | 5 | @Entity() 6 | export class Category { 7 | 8 | @PrimaryGeneratedColumn() 9 | id!: number; 10 | 11 | @Column({ type: String }) 12 | name!: string; 13 | 14 | } 15 | -------------------------------------------------------------------------------- /test/github-issues/1261/entity/Foo.ts: -------------------------------------------------------------------------------- 1 | import {Entity} from "../../../../src/decorator/entity/Entity.ts"; 2 | import {PrimaryGeneratedColumn} from "../../../../src/decorator/columns/PrimaryGeneratedColumn.ts"; 3 | import {BaseEntity} from "../../../../src/repository/BaseEntity.ts"; 4 | 5 | @Entity() 6 | export class Foo extends BaseEntity { 7 | 8 | @PrimaryGeneratedColumn() 9 | id!: number; 10 | 11 | } 12 | -------------------------------------------------------------------------------- /sample/sample13-everywhere-abstraction/entity/PostUser.ts: -------------------------------------------------------------------------------- 1 | import {Column, Entity, PrimaryGeneratedColumn} from "../../../src/index"; 2 | 3 | @Entity("sample13_post_user") 4 | export class PostUser { 5 | 6 | @PrimaryGeneratedColumn() 7 | id: number; 8 | 9 | @Column("int") 10 | name: string; 11 | 12 | @Column() 13 | firstName: string; 14 | 15 | @Column() 16 | secondName: string; 17 | 18 | } -------------------------------------------------------------------------------- /sample/sample26-embedded-tables/entity/Question.ts: -------------------------------------------------------------------------------- 1 | import {Column, Entity, PrimaryGeneratedColumn} from "../../../src/index"; 2 | import {Counters} from "./Counters"; 3 | 4 | @Entity("sample26_question") 5 | export class Question { 6 | 7 | @PrimaryGeneratedColumn() 8 | id: number; 9 | 10 | @Column() 11 | title: string; 12 | 13 | @Column(type => Counters) 14 | counters: Counters; 15 | 16 | } -------------------------------------------------------------------------------- /sample/sample27-composite-primary-keys/entity/Post.ts: -------------------------------------------------------------------------------- 1 | import {Column, Entity} from "../../../src/index"; 2 | import {PrimaryColumn} from "../../../src/decorator/columns/PrimaryColumn"; 3 | 4 | @Entity("sample27_composite_primary_keys") 5 | export class Post { 6 | 7 | @PrimaryColumn("int") 8 | id: number; 9 | 10 | @PrimaryColumn() 11 | type: string; 12 | 13 | @Column() 14 | text: string; 15 | 16 | } -------------------------------------------------------------------------------- /src/decorator/options/ValueTransformer.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Interface for objects that deal with (un)marshalling data. 3 | */ 4 | export interface ValueTransformer { 5 | 6 | /** 7 | * Used to marshal data when writing to the database. 8 | */ 9 | to(value: any): any; 10 | 11 | /** 12 | * Used to unmarshal data when reading from the database. 13 | */ 14 | from(value: any): any; 15 | 16 | } 17 | -------------------------------------------------------------------------------- /test/functional/embedded/embedded-many-to-many-case3/entity/Subcounters.ts: -------------------------------------------------------------------------------- 1 | import {Column} from "../../../../../src/decorator/columns/Column.ts"; 2 | import {PrimaryColumn} from "../../../../../src/decorator/columns/PrimaryColumn.ts"; 3 | 4 | export class Subcounters { 5 | 6 | @PrimaryColumn({ type: Number }) 7 | version!: number; 8 | 9 | @Column({ type: Number }) 10 | watches!: number; 11 | 12 | } 13 | -------------------------------------------------------------------------------- /test/functional/embedded/embedded-many-to-many-case5/entity/Subcounters.ts: -------------------------------------------------------------------------------- 1 | import {Column} from "../../../../../src/decorator/columns/Column.ts"; 2 | import {PrimaryColumn} from "../../../../../src/decorator/columns/PrimaryColumn.ts"; 3 | 4 | export class Subcounters { 5 | 6 | @PrimaryColumn({ type: Number }) 7 | version!: number; 8 | 9 | @Column({ type: Number }) 10 | watches!: number; 11 | 12 | } 13 | -------------------------------------------------------------------------------- /test/functional/embedded/embedded-many-to-one-case3/entity/Subcounters.ts: -------------------------------------------------------------------------------- 1 | import {Column} from "../../../../../src/decorator/columns/Column.ts"; 2 | import {PrimaryColumn} from "../../../../../src/decorator/columns/PrimaryColumn.ts"; 3 | 4 | export class Subcounters { 5 | 6 | @PrimaryColumn({ type: Number }) 7 | version!: number; 8 | 9 | @Column({ type: Number }) 10 | watches!: number; 11 | 12 | } 13 | -------------------------------------------------------------------------------- /test/functional/embedded/embedded-many-to-one-case5/entity/Subcounters.ts: -------------------------------------------------------------------------------- 1 | import {Column} from "../../../../../src/decorator/columns/Column.ts"; 2 | import {PrimaryColumn} from "../../../../../src/decorator/columns/PrimaryColumn.ts"; 3 | 4 | export class Subcounters { 5 | 6 | @PrimaryColumn({ type: Number }) 7 | version!: number; 8 | 9 | @Column({ type: Number }) 10 | watches!: number; 11 | 12 | } 13 | -------------------------------------------------------------------------------- /test/functional/embedded/embedded-with-special-columns/entity/Subcounters.ts: -------------------------------------------------------------------------------- 1 | import {Column} from "../../../../../src/decorator/columns/Column.ts"; 2 | import {VersionColumn} from "../../../../../src/decorator/columns/VersionColumn.ts"; 3 | 4 | export class Subcounters { 5 | 6 | @VersionColumn({ type: Number }) 7 | version!: number; 8 | 9 | @Column({ type: Number }) 10 | watches!: number; 11 | 12 | } 13 | -------------------------------------------------------------------------------- /test/functional/embedded/prefix/entity/Counters.ts: -------------------------------------------------------------------------------- 1 | import {Column} from "../../../../../src/decorator/columns/Column.ts"; 2 | 3 | export class Counters { 4 | 5 | @Column({ name: "_likes", type: Number }) 6 | likes!: number; 7 | 8 | @Column({ name: "_comments", type: Number }) 9 | comments!: number; 10 | 11 | @Column({ name: "_favorites", type: Number }) 12 | favorites!: number; 13 | 14 | } 15 | -------------------------------------------------------------------------------- /test/functional/view-entity/postgres/entity/Category.ts: -------------------------------------------------------------------------------- 1 | import {Entity} from "../../../../../src/index.ts"; 2 | import {Column} from "../../../../../src/index.ts"; 3 | import {PrimaryGeneratedColumn} from "../../../../../src/index.ts"; 4 | 5 | @Entity() 6 | export class Category { 7 | 8 | @PrimaryGeneratedColumn() 9 | id!: number; 10 | 11 | @Column({ type: String }) 12 | name!: string; 13 | 14 | } 15 | -------------------------------------------------------------------------------- /test/github-issues/2800/entity/Vehicle.ts: -------------------------------------------------------------------------------- 1 | import {Entity, PrimaryGeneratedColumn, TableInheritance} from "../../../../src/index.ts"; 2 | 3 | export abstract class Engine {} 4 | 5 | @Entity() 6 | @TableInheritance({ column: { name: "type", type: "varchar" }}) 7 | export abstract class Vehicle { 8 | 9 | @PrimaryGeneratedColumn() 10 | public id?: number; 11 | 12 | public abstract engine: Engine; 13 | 14 | } 15 | -------------------------------------------------------------------------------- /test/other-issues/nested-child-entities/entity/SquadBilliardsTournament.ts: -------------------------------------------------------------------------------- 1 | import {ChildEntity} from "../../../../src/index.ts"; 2 | 3 | import {BilliardsTournament} from "./BilliardsTournament.ts"; 4 | 5 | @ChildEntity() 6 | export class SquadBilliardsTournament extends BilliardsTournament { 7 | constructor(squadBilliardsTournament?: {name: string}) { 8 | super(squadBilliardsTournament); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /src/commands/types.ts: -------------------------------------------------------------------------------- 1 | import yargs from "../../vendor/https/deno.land/x/yargs/deno.ts"; 2 | import type { Arguments } from "../../vendor/https/deno.land/x/yargs/deno-types.ts"; 3 | 4 | export type Argv = ReturnType; 5 | export type { Arguments }; 6 | 7 | export interface CommandModule { 8 | command: string 9 | describe: string 10 | builder?(args: Argv): any 11 | handler(args: Arguments): any 12 | } -------------------------------------------------------------------------------- /src/metadata-args/CheckMetadataArgs.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Arguments for CheckMetadata class. 3 | */ 4 | export interface CheckMetadataArgs { 5 | 6 | /** 7 | * Class to which index is applied. 8 | */ 9 | target: Function|string; 10 | 11 | /** 12 | * Check constraint name. 13 | */ 14 | name?: string; 15 | 16 | /** 17 | * Check expression. 18 | */ 19 | expression: string; 20 | } 21 | -------------------------------------------------------------------------------- /test/functional/mongodb/basic/mongo-embeddeds-index/entity/Information.ts: -------------------------------------------------------------------------------- 1 | import {Column} from "../../../../../../src/decorator/columns/Column.ts"; 2 | import {Index} from "../../../../../../src/decorator/Index.ts"; 3 | 4 | export class Information { 5 | 6 | @Column({ type: String }) 7 | description!: string; 8 | 9 | @Column({ type: Number }) 10 | @Index("post_likes") 11 | likes!: number; 12 | 13 | } 14 | -------------------------------------------------------------------------------- /test/functional/table-inheritance/single-table/basic-functionality/entity/Student.ts: -------------------------------------------------------------------------------- 1 | import {Column} from "../../../../../../src/decorator/columns/Column.ts"; 2 | import {ChildEntity} from "../../../../../../src/decorator/entity/ChildEntity.ts"; 3 | import {Person} from "./Person.ts"; 4 | 5 | @ChildEntity() 6 | export class Student extends Person { 7 | 8 | @Column({ type: String }) 9 | faculty!: string; 10 | 11 | } 12 | -------------------------------------------------------------------------------- /test/github-issues/1972/entity/TournamentParticipant.ts: -------------------------------------------------------------------------------- 1 | import { Entity, TableInheritance, PrimaryGeneratedColumn } from "../../../../src/index.ts"; 2 | 3 | @Entity() 4 | @TableInheritance({ 5 | pattern: "STI", 6 | column: { 7 | name: "type", 8 | type: "varchar", 9 | }, 10 | }) 11 | export abstract class TournamentParticipant { 12 | @PrimaryGeneratedColumn() 13 | public id!: number; 14 | } 15 | -------------------------------------------------------------------------------- /test/github-issues/5174/entity/Role.ts: -------------------------------------------------------------------------------- 1 | import {Entity} from "../../../../src/decorator/entity/Entity.ts"; 2 | import {PrimaryColumn, OneToMany} from "../../../../src/index.ts"; 3 | import {User} from "./User.ts"; 4 | 5 | @Entity() 6 | export class Role { 7 | 8 | @PrimaryColumn({ type: String }) 9 | id!: string; 10 | 11 | @OneToMany(_ => User, user => user.role, { cascade: true }) 12 | users!: User[]; 13 | 14 | } 15 | -------------------------------------------------------------------------------- /test/other-issues/nested-child-entities/entity/BilliardsTournament.ts: -------------------------------------------------------------------------------- 1 | import {ChildEntity} from "../../../../src/index.ts"; 2 | 3 | import {Tournament} from "./Tournament.ts"; 4 | 5 | @ChildEntity() // Causes Error of duplicated column in generated sql 6 | export class BilliardsTournament extends Tournament { 7 | constructor(billiardsTournament?: {name: string}) { 8 | super(billiardsTournament); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # These are supported funding model platforms 2 | 3 | github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] 4 | patreon: # Replace with a single Patreon username 5 | open_collective: typeorm 6 | ko_fi: # Replace with a single Ko-fi username 7 | tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel 8 | custom: # Replace with a single custom sponsorship URL 9 | -------------------------------------------------------------------------------- /src/decorator/options/SpatialColumnOptions.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Options for spatial columns. 3 | */ 4 | export interface SpatialColumnOptions { 5 | 6 | /** 7 | * Column type's feature type. 8 | * Geometry, Point, Polygon, etc. 9 | */ 10 | spatialFeatureType?: string; 11 | 12 | /** 13 | * Column type's SRID. 14 | * Spatial Reference ID or EPSG code. 15 | */ 16 | srid?: number; 17 | 18 | } 19 | -------------------------------------------------------------------------------- /test/functional/table-inheritance/single-table/basic-functionality/entity/Employee.ts: -------------------------------------------------------------------------------- 1 | import {Column} from "../../../../../../src/decorator/columns/Column.ts"; 2 | import {ChildEntity} from "../../../../../../src/decorator/entity/ChildEntity.ts"; 3 | import {Person} from "./Person.ts"; 4 | 5 | @ChildEntity() 6 | export class Employee extends Person { 7 | 8 | @Column({ type: Number }) 9 | salary!: number; 10 | 11 | } 12 | -------------------------------------------------------------------------------- /test/github-issues/3379/entity/Post.ts: -------------------------------------------------------------------------------- 1 | import {Index, PrimaryGeneratedColumn} from "../../../../src/index.ts"; 2 | import {Column} from "../../../../src/index.ts"; 3 | import {Entity} from "../../../../src/index.ts"; 4 | 5 | @Index("name_index", ["name"]) 6 | @Entity() 7 | export class Post { 8 | 9 | @PrimaryGeneratedColumn() 10 | id!: number; 11 | 12 | @Column({ type: String }) 13 | name!: string; 14 | 15 | } 16 | -------------------------------------------------------------------------------- /sample/sample32-migrations/entity/Post.ts: -------------------------------------------------------------------------------- 1 | import {Column, Entity, ManyToOne, PrimaryGeneratedColumn} from "../../../src/index"; 2 | import {Author} from "./Author"; 3 | 4 | @Entity() 5 | export class Post { 6 | 7 | @PrimaryGeneratedColumn() 8 | id: number; 9 | 10 | @Column() 11 | title: string; 12 | 13 | @ManyToOne(type => Author, { 14 | cascade: ["insert"] 15 | }) 16 | author: Author; 17 | 18 | } -------------------------------------------------------------------------------- /test/functional/embedded/multiple-primary-columns-with-nested-embed/entity/Subcounters.ts: -------------------------------------------------------------------------------- 1 | import {Column} from "../../../../../src/decorator/columns/Column.ts"; 2 | import {PrimaryColumn} from "../../../../../src/decorator/columns/PrimaryColumn.ts"; 3 | 4 | export class Subcounters { 5 | 6 | @PrimaryColumn({ type: Number }) 7 | version!: number; 8 | 9 | @Column({ type: Number }) 10 | watches!: number; 11 | 12 | } 13 | -------------------------------------------------------------------------------- /test/functional/table-inheritance/single-table/relations/many-to-many/entity/Employee.ts: -------------------------------------------------------------------------------- 1 | import {Column} from "../../../../../../../src/decorator/columns/Column.ts"; 2 | import {ChildEntity} from "../../../../../../../src/decorator/entity/ChildEntity.ts"; 3 | import {Person} from "./Person.ts"; 4 | 5 | @ChildEntity() 6 | export class Employee extends Person { 7 | 8 | @Column({ type: Number }) 9 | salary!: number; 10 | 11 | } 12 | -------------------------------------------------------------------------------- /test/functional/table-inheritance/single-table/relations/one-to-many/entity/Employee.ts: -------------------------------------------------------------------------------- 1 | import {Column} from "../../../../../../../src/decorator/columns/Column.ts"; 2 | import {ChildEntity} from "../../../../../../../src/decorator/entity/ChildEntity.ts"; 3 | import {Person} from "./Person.ts"; 4 | 5 | @ChildEntity() 6 | export class Employee extends Person { 7 | 8 | @Column({ type: Number }) 9 | salary!: number; 10 | 11 | } 12 | -------------------------------------------------------------------------------- /test/github-issues/1623/entity/User.ts: -------------------------------------------------------------------------------- 1 | import {Column, Entity, PrimaryGeneratedColumn} from "../../../../src/index.ts"; 2 | 3 | @Entity() 4 | export class User { 5 | 6 | @PrimaryGeneratedColumn() 7 | id!: number; 8 | 9 | @Column({ type: String }) 10 | firstName!: string; 11 | 12 | @Column({ type: String }) 13 | lastName!: string; 14 | 15 | @Column({ type: Number }) 16 | age!: number; 17 | 18 | } 19 | -------------------------------------------------------------------------------- /test/github-issues/1716/entity/mysqlEntity.ts: -------------------------------------------------------------------------------- 1 | import { PrimaryColumn, Entity, Column } from "../../../../src/index.ts"; 2 | 3 | @Entity() 4 | export class MysqlEntity { 5 | 6 | @PrimaryColumn({ type: Number }) 7 | id!: number; 8 | 9 | @Column("time") 10 | fieldTime!: Date; 11 | 12 | @Column("timestamp") 13 | fieldTimestamp!: Date; 14 | 15 | @Column("datetime") 16 | fieldDatetime!: Date; 17 | 18 | } 19 | -------------------------------------------------------------------------------- /test/github-issues/4782/entity/Item.ts: -------------------------------------------------------------------------------- 1 | import { CreateDateColumn } from "../../../../src/index.ts"; 2 | import { PrimaryGeneratedColumn } from "../../../../src/decorator/columns/PrimaryGeneratedColumn.ts"; 3 | import { Entity } from "../../../../src/decorator/entity/Entity.ts"; 4 | 5 | @Entity() 6 | export class Item { 7 | @PrimaryGeneratedColumn() 8 | id!: number; 9 | 10 | @CreateDateColumn() 11 | date!: Date; 12 | } 13 | -------------------------------------------------------------------------------- /test/other-issues/take-multiple-pk/entity/Role.ts: -------------------------------------------------------------------------------- 1 | import {Column} from "../../../../src/decorator/columns/Column.ts"; 2 | import {PrimaryGeneratedColumn} from "../../../../src/decorator/columns/PrimaryGeneratedColumn.ts"; 3 | import {Entity} from "../../../../src/decorator/entity/Entity.ts"; 4 | 5 | @Entity() 6 | export class Role { 7 | @PrimaryGeneratedColumn() id!: number; 8 | 9 | @Column({ type: String }) name!: string; 10 | } 11 | -------------------------------------------------------------------------------- /sample/sample33-custom-repository/entity/Post.ts: -------------------------------------------------------------------------------- 1 | import {Column, Entity, ManyToOne, PrimaryGeneratedColumn} from "../../../src/index"; 2 | import {Author} from "./Author"; 3 | 4 | @Entity() 5 | export class Post { 6 | 7 | @PrimaryGeneratedColumn() 8 | id: number; 9 | 10 | @Column() 11 | title: string; 12 | 13 | @ManyToOne(type => Author, { 14 | cascade: ["insert"] 15 | }) 16 | author: Author; 17 | 18 | } -------------------------------------------------------------------------------- /src/error/ConnectionNotFoundError.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Thrown when consumer tries to get connection that does not exist. 3 | */ 4 | export class ConnectionNotFoundError extends Error { 5 | name = "ConnectionNotFoundError"; 6 | 7 | constructor(name: string) { 8 | super(); 9 | Object.setPrototypeOf(this, ConnectionNotFoundError.prototype); 10 | this.message = `Connection "${name}" was not found.`; 11 | } 12 | 13 | } -------------------------------------------------------------------------------- /test/functional/connection/schema/photo.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Photo", 3 | "table": { 4 | "name": "photo" 5 | }, 6 | "columns": { 7 | "id": { 8 | "type": "int", 9 | "primary": true, 10 | "generated": true 11 | }, 12 | "description": { 13 | "type": "varchar", 14 | "nullable": false 15 | }, 16 | "url": { 17 | "type": "varchar", 18 | "nullable": false 19 | } 20 | } 21 | } -------------------------------------------------------------------------------- /test/functional/connection/schema/user.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "User", 3 | "table": { 4 | "name": "user" 5 | }, 6 | "columns": { 7 | "id": { 8 | "type": "int", 9 | "primary": true, 10 | "generated": true 11 | }, 12 | "firstName": { 13 | "type": "varchar", 14 | "nullable": false 15 | }, 16 | "secondName": { 17 | "type": "varchar", 18 | "nullable": false 19 | } 20 | } 21 | } -------------------------------------------------------------------------------- /test/functional/mongodb/basic/array-columns/entity/Counters.ts: -------------------------------------------------------------------------------- 1 | import {Column} from "../../../../../../src/decorator/columns/Column.ts"; 2 | 3 | export class Counters { 4 | 5 | @Column({ type: Number }) 6 | likes!: number; 7 | 8 | @Column({ type: String }) 9 | text!: string; 10 | 11 | constructor(likes: number, text: string) { 12 | this.likes = likes; 13 | this.text = text; 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /test/functional/sqljs/entity/Post.ts: -------------------------------------------------------------------------------- 1 | import {Entity} from "../../../../src/decorator/entity/Entity.ts"; 2 | import {Column} from "../../../../src/decorator/columns/Column.ts"; 3 | import {PrimaryColumn} from "../../../../src/decorator/columns/PrimaryColumn.ts"; 4 | 5 | @Entity() 6 | export class Post { 7 | 8 | @PrimaryColumn({ type: Number }) 9 | id!: number; 10 | 11 | @Column({ type: String }) 12 | title!: string; 13 | } 14 | -------------------------------------------------------------------------------- /test/functional/table-inheritance/single-table/basic-functionality/entity/Accountant.ts: -------------------------------------------------------------------------------- 1 | import {Column} from "../../../../../../src/decorator/columns/Column.ts"; 2 | import {ChildEntity} from "../../../../../../src/decorator/entity/ChildEntity.ts"; 3 | import {Employee} from "./Employee.ts"; 4 | 5 | @ChildEntity() 6 | export class Accountant extends Employee { 7 | 8 | @Column({ type: String }) 9 | department!: string; 10 | 11 | } 12 | -------------------------------------------------------------------------------- /test/functional/table-inheritance/single-table/basic-functionality/entity/Teacher.ts: -------------------------------------------------------------------------------- 1 | import {Column} from "../../../../../../src/decorator/columns/Column.ts"; 2 | import {ChildEntity} from "../../../../../../src/decorator/entity/ChildEntity.ts"; 3 | import {Employee} from "./Employee.ts"; 4 | 5 | @ChildEntity() 6 | export class Teacher extends Employee { 7 | 8 | @Column({ type: String }) 9 | specialization!: string; 10 | 11 | } 12 | -------------------------------------------------------------------------------- /test/github-issues/1416/entity/Author.ts: -------------------------------------------------------------------------------- 1 | import {Column, Entity, PrimaryGeneratedColumn, OneToMany} from "../../../../src/index.ts"; 2 | import {Photo} from "./Photo.ts"; 3 | 4 | @Entity() 5 | export class Author { 6 | 7 | @PrimaryGeneratedColumn() 8 | id!: number; 9 | 10 | @Column({ type: String }) 11 | name!: string; 12 | 13 | @OneToMany(type => Photo, photo => photo.author) 14 | photos!: Photo[]; 15 | 16 | } 17 | -------------------------------------------------------------------------------- /test/github-issues/1716/entity/mariadbEntity.ts: -------------------------------------------------------------------------------- 1 | import { PrimaryColumn, Entity, Column } from "../../../../src/index.ts"; 2 | 3 | @Entity() 4 | export class MariadbEntity { 5 | 6 | @PrimaryColumn({ type: Number }) 7 | id!: number; 8 | 9 | @Column("time") 10 | fieldTime!: Date; 11 | 12 | @Column("timestamp") 13 | fieldTimestamp!: Date; 14 | 15 | @Column("datetime") 16 | fieldDatetime!: Date; 17 | 18 | } 19 | -------------------------------------------------------------------------------- /test/github-issues/2005/entity/User.ts: -------------------------------------------------------------------------------- 1 | import {Column, Entity, PrimaryGeneratedColumn} from "../../../../src/index.ts"; 2 | 3 | @Entity() 4 | export class User { 5 | 6 | @PrimaryGeneratedColumn() 7 | id!: number; 8 | 9 | @Column({ 10 | type: "tinyint", 11 | transformer: { 12 | from: val => !!val, 13 | to: val => val, 14 | }, 15 | }) 16 | activated!: boolean; 17 | 18 | } 19 | -------------------------------------------------------------------------------- /test/other-issues/nested-child-entities/entity/TournamentGraph.ts: -------------------------------------------------------------------------------- 1 | import {Entity, PrimaryGeneratedColumn, OneToOne} from "../../../../src/index.ts"; 2 | 3 | import {Tournament} from "./Tournament.ts"; 4 | 5 | @Entity() 6 | export class TournamentGraph { 7 | @PrimaryGeneratedColumn() 8 | public id!: number; 9 | 10 | @OneToOne(type => Tournament, tournament => tournament.graph) 11 | public tournament!: Tournament; 12 | } 13 | -------------------------------------------------------------------------------- /src/metadata-args/ExclusionMetadataArgs.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Arguments for ExclusionMetadata class. 3 | */ 4 | export interface ExclusionMetadataArgs { 5 | 6 | /** 7 | * Class to which index is applied. 8 | */ 9 | target: Function|string; 10 | 11 | /** 12 | * Exclusion constraint name. 13 | */ 14 | name?: string; 15 | 16 | /** 17 | * Exclusion expression. 18 | */ 19 | expression: string; 20 | } 21 | -------------------------------------------------------------------------------- /test/github-issues/1972/entity/User.ts: -------------------------------------------------------------------------------- 1 | import { Entity, PrimaryGeneratedColumn, Column } from "../../../../src/index.ts"; 2 | 3 | @Entity() 4 | export class User { 5 | @PrimaryGeneratedColumn() 6 | public id!: number; 7 | 8 | @Column({ type: String }) 9 | public name!: string; 10 | 11 | constructor(user?: { name: string }) { 12 | if (user) { 13 | this.name = user.name; 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /test/github-issues/306/entity/Duration.ts: -------------------------------------------------------------------------------- 1 | import {Column} from "../../../../src/decorator/columns/Column.ts"; 2 | 3 | export class Duration { 4 | 5 | @Column({ type: Number, name: "duration_minutes" }) 6 | durationMinutes!: number; 7 | 8 | @Column({ type: Number, name: "duration_hours" }) 9 | durationHours!: number; 10 | 11 | @Column({ type: Number, name: "duration_days" }) 12 | durationDays!: number; 13 | 14 | } 15 | -------------------------------------------------------------------------------- /test/github-issues/363/entity/Car.ts: -------------------------------------------------------------------------------- 1 | import {Entity} from "../../../../src/decorator/entity/Entity.ts"; 2 | import {PrimaryGeneratedColumn} from "../../../../src/decorator/columns/PrimaryGeneratedColumn.ts"; 3 | import {Column} from "../../../../src/decorator/columns/Column.ts"; 4 | 5 | @Entity() 6 | export class Car { 7 | @PrimaryGeneratedColumn() 8 | id!: number; 9 | 10 | @Column({ type: String }) 11 | name!: string; 12 | } 13 | -------------------------------------------------------------------------------- /test/github-issues/3949/entity/Post.ts: -------------------------------------------------------------------------------- 1 | import {Entity} from "../../../../src/decorator/entity/Entity.ts"; 2 | import {Column} from "../../../../src/decorator/columns/Column.ts"; 3 | import {PrimaryColumn} from "../../../../src/decorator/columns/PrimaryColumn.ts"; 4 | 5 | @Entity() 6 | export class Post { 7 | 8 | @PrimaryColumn({ type: Number }) 9 | id!: number; 10 | 11 | @Column({ type: Date }) 12 | date!: Date; 13 | 14 | } 15 | -------------------------------------------------------------------------------- /test/github-issues/479/entity/Car.ts: -------------------------------------------------------------------------------- 1 | import {Entity} from "../../../../src/decorator/entity/Entity.ts"; 2 | import {PrimaryGeneratedColumn} from "../../../../src/decorator/columns/PrimaryGeneratedColumn.ts"; 3 | import {Column} from "../../../../src/decorator/columns/Column.ts"; 4 | 5 | @Entity() 6 | export class Car { 7 | @PrimaryGeneratedColumn() 8 | id!: number; 9 | 10 | @Column({ type: String }) 11 | name!: string; 12 | } 13 | -------------------------------------------------------------------------------- /test/github-issues/521/entity/Car.ts: -------------------------------------------------------------------------------- 1 | import {Entity} from "../../../../src/decorator/entity/Entity.ts"; 2 | import {PrimaryGeneratedColumn} from "../../../../src/decorator/columns/PrimaryGeneratedColumn.ts"; 3 | import {Column} from "../../../../src/decorator/columns/Column.ts"; 4 | 5 | @Entity() 6 | export class Car { 7 | @PrimaryGeneratedColumn() 8 | id!: number; 9 | 10 | @Column({ type: String }) 11 | name!: string; 12 | } 13 | -------------------------------------------------------------------------------- /sample/sample16-indexes/entity/BasePost.ts: -------------------------------------------------------------------------------- 1 | import {Column, PrimaryGeneratedColumn} from "../../../src/index"; 2 | import {Index} from "../../../src/decorator/Index"; 3 | 4 | @Index("my_index_with_id_and_text", ["id", "text"]) 5 | export class BasePost { 6 | 7 | @PrimaryGeneratedColumn() 8 | id: number; 9 | 10 | @Column({ unique: true }) 11 | text: string; 12 | 13 | @Index() 14 | @Column() 15 | extra: string; 16 | 17 | } -------------------------------------------------------------------------------- /sample/sample2-one-to-one/entity/PostImage.ts: -------------------------------------------------------------------------------- 1 | import {Column, Entity, OneToOne, PrimaryGeneratedColumn} from "../../../src/index.ts"; 2 | import {Post} from "./Post.ts"; 3 | 4 | @Entity("sample2_post_image") 5 | export class PostImage { 6 | 7 | @PrimaryGeneratedColumn() 8 | id: number; 9 | 10 | @Column({ type: String }) 11 | url: string; 12 | 13 | @OneToOne(type => Post, post => post.image) 14 | post: Post; 15 | 16 | } 17 | -------------------------------------------------------------------------------- /src/decorator/options/PrimaryGeneratedColumnUUIDOptions.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Describes all options for PrimaryGeneratedColumn decorator with numeric uuid strategy. 3 | */ 4 | export interface PrimaryGeneratedColumnUUIDOptions { 5 | 6 | /** 7 | * Column name in the database. 8 | */ 9 | name?: string; 10 | 11 | /** 12 | * Column comment. Not supported by all database types. 13 | */ 14 | comment?: string; 15 | 16 | } 17 | -------------------------------------------------------------------------------- /src/driver/expo/ExpoConnectionOptions.ts: -------------------------------------------------------------------------------- 1 | import {BaseConnectionOptions} from "../../connection/BaseConnectionOptions.ts"; 2 | 3 | /** 4 | * Sqlite-specific connection options. 5 | */ 6 | export interface ExpoConnectionOptions extends BaseConnectionOptions { 7 | 8 | /** 9 | * Database type. 10 | */ 11 | readonly type: "expo"; 12 | 13 | /** 14 | * Database name. 15 | */ 16 | readonly database: string; 17 | } 18 | -------------------------------------------------------------------------------- /test/github-issues/1591/entity/User.ts: -------------------------------------------------------------------------------- 1 | import {Column, Entity, JoinTable, ManyToMany, PrimaryGeneratedColumn} from "../../../../src/index.ts"; 2 | import {Photo} from "./Photo.ts"; 3 | 4 | @Entity() 5 | export class User { 6 | 7 | @PrimaryGeneratedColumn() 8 | id!: number; 9 | 10 | @Column({ type: String }) 11 | name!: string; 12 | 13 | @ManyToMany(type => Photo) 14 | @JoinTable() 15 | photos!: Photo[]; 16 | 17 | } 18 | -------------------------------------------------------------------------------- /test/github-issues/1901/entity/Post.ts: -------------------------------------------------------------------------------- 1 | import {Entity, PrimaryGeneratedColumn} from "../../../../src/index.ts"; 2 | import {Column} from "../../../../src/decorator/columns/Column.ts"; 3 | 4 | @Entity() 5 | export class Post { 6 | 7 | @PrimaryGeneratedColumn() 8 | id!: number; 9 | 10 | @Column("timestamp", { precision: 3, default: () => "CURRENT_TIMESTAMP(3)", onUpdate: "CURRENT_TIMESTAMP(3)"}) 11 | updateAt!: Date; 12 | 13 | } 14 | -------------------------------------------------------------------------------- /test/github-issues/352/entity/Post.ts: -------------------------------------------------------------------------------- 1 | import {Entity} from "../../../../src/decorator/entity/Entity.ts"; 2 | import {Column} from "../../../../src/decorator/columns/Column.ts"; 3 | import {PrimaryColumn} from "../../../../src/decorator/columns/PrimaryColumn.ts"; 4 | 5 | @Entity() 6 | export class Post { 7 | 8 | @PrimaryColumn("double precision") 9 | id!: number; 10 | 11 | @Column({ type: String }) 12 | title!: string; 13 | 14 | } 15 | -------------------------------------------------------------------------------- /test/github-issues/363/entity/Fruit.ts: -------------------------------------------------------------------------------- 1 | import {Entity} from "../../../../src/decorator/entity/Entity.ts"; 2 | import {PrimaryGeneratedColumn} from "../../../../src/decorator/columns/PrimaryGeneratedColumn.ts"; 3 | import {Column} from "../../../../src/decorator/columns/Column.ts"; 4 | 5 | @Entity() 6 | export class Fruit { 7 | @PrimaryGeneratedColumn() 8 | id!: number; 9 | 10 | @Column({ type: String }) 11 | name!: string; 12 | } 13 | -------------------------------------------------------------------------------- /test/github-issues/4701/migration/1567759789051-ExampleMigration.ts: -------------------------------------------------------------------------------- 1 | import { MigrationInterface } from "../../../../src/migration/MigrationInterface.ts"; 2 | import { QueryRunner } from "../../../../src/query-runner/QueryRunner.ts"; 3 | 4 | export class ExampleMigrationOne1567759789051 implements MigrationInterface { 5 | public async up(queryRunner: QueryRunner): Promise {} 6 | public async down(queryRunner: QueryRunner): Promise {} 7 | } 8 | -------------------------------------------------------------------------------- /test/github-issues/4701/migration/1567759832591-ExampleMigrationTwo.ts: -------------------------------------------------------------------------------- 1 | import { MigrationInterface } from "../../../../src/migration/MigrationInterface.ts"; 2 | import { QueryRunner } from "../../../../src/query-runner/QueryRunner.ts"; 3 | 4 | export class ExampleMigrationOne1567759789051 implements MigrationInterface { 5 | public async up(queryRunner: QueryRunner): Promise {} 6 | public async down(queryRunner: QueryRunner): Promise {} 7 | } 8 | -------------------------------------------------------------------------------- /test/github-issues/493/entity/Post.ts: -------------------------------------------------------------------------------- 1 | import {Entity} from "../../../../src/decorator/entity/Entity.ts"; 2 | import {Column} from "../../../../src/decorator/columns/Column.ts"; 3 | import {PrimaryColumn} from "../../../../src/decorator/columns/PrimaryColumn.ts"; 4 | 5 | @Entity() 6 | export class Post { 7 | 8 | @PrimaryColumn({ type: String }) 9 | id!: string; 10 | 11 | @Column({ type: String }) 12 | title!: string; 13 | 14 | } 15 | -------------------------------------------------------------------------------- /sample/sample2-one-to-one/entity/PostAuthor.ts: -------------------------------------------------------------------------------- 1 | import {Column, Entity, OneToOne, PrimaryGeneratedColumn} from "../../../src/index.ts"; 2 | import {Post} from "./Post.ts"; 3 | 4 | @Entity("sample2_post_author") 5 | export class PostAuthor { 6 | 7 | @PrimaryGeneratedColumn() 8 | id: number; 9 | 10 | @Column({ type: String }) 11 | name: string; 12 | 13 | @OneToOne(type => Post, post => post.author) 14 | post: Post; 15 | 16 | } 17 | -------------------------------------------------------------------------------- /sample/sample26-embedded-tables/entity/Post.ts: -------------------------------------------------------------------------------- 1 | import {Column, Entity, PrimaryGeneratedColumn} from "../../../src/index"; 2 | import {Counters} from "./Counters"; 3 | 4 | @Entity("sample26_post") 5 | export class Post { 6 | 7 | @PrimaryGeneratedColumn() 8 | id: number; 9 | 10 | @Column() 11 | title: string; 12 | 13 | @Column() 14 | text: string; 15 | 16 | @Column(type => Counters) 17 | counters: Counters; 18 | 19 | } -------------------------------------------------------------------------------- /sample/sample3-many-to-one/entity/PostImage.ts: -------------------------------------------------------------------------------- 1 | import {Column, Entity, OneToMany, PrimaryGeneratedColumn} from "../../../src/index.ts"; 2 | import {Post} from "./Post.ts"; 3 | 4 | @Entity("sample3_post_image") 5 | export class PostImage { 6 | 7 | @PrimaryGeneratedColumn() 8 | id: number; 9 | 10 | @Column({ type: String }) 11 | url: string; 12 | 13 | @OneToMany(type => Post, post => post.image) 14 | posts: Post[]; 15 | 16 | } 17 | -------------------------------------------------------------------------------- /test/functional/query-builder/relation-id/many-to-one/embedded-with-multiple-pk/entity/User.ts: -------------------------------------------------------------------------------- 1 | import {Entity} from "../../../../../../../src/decorator/entity/Entity.ts"; 2 | import {PrimaryColumn} from "../../../../../../../src/decorator/columns/PrimaryColumn.ts"; 3 | 4 | @Entity() 5 | export class User { 6 | 7 | @PrimaryColumn({ type: Number }) 8 | id!: number; 9 | 10 | @PrimaryColumn({ type: String }) 11 | name!: string; 12 | 13 | } 14 | -------------------------------------------------------------------------------- /test/functional/query-builder/relation-id/one-to-one/embedded-with-multiple-pk/entity/User.ts: -------------------------------------------------------------------------------- 1 | import {Entity} from "../../../../../../../src/decorator/entity/Entity.ts"; 2 | import {PrimaryColumn} from "../../../../../../../src/decorator/columns/PrimaryColumn.ts"; 3 | 4 | @Entity() 5 | export class User { 6 | 7 | @PrimaryColumn({ type: Number }) 8 | id!: number; 9 | 10 | @PrimaryColumn({ type: String }) 11 | name!: string; 12 | 13 | } 14 | -------------------------------------------------------------------------------- /test/functional/repository/clear/entity/Post.ts: -------------------------------------------------------------------------------- 1 | import {Entity} from "../../../../../src/decorator/entity/Entity.ts"; 2 | import {Column} from "../../../../../src/decorator/columns/Column.ts"; 3 | import {PrimaryColumn} from "../../../../../src/decorator/columns/PrimaryColumn.ts"; 4 | 5 | @Entity() 6 | export class Post { 7 | 8 | @PrimaryColumn("int") 9 | id!: number; 10 | 11 | @Column({ type: String }) 12 | title!: string; 13 | 14 | } 15 | -------------------------------------------------------------------------------- /test/functional/table-inheritance/single-table/database-option-inherited/entity/Person.ts: -------------------------------------------------------------------------------- 1 | import {Column, Entity, PrimaryGeneratedColumn, TableInheritance} from "../../../../../../src/index.ts"; 2 | 3 | @Entity({database: "test"}) 4 | @TableInheritance({column: {name: "type", type: "varchar"}}) 5 | export class Person { 6 | 7 | @PrimaryGeneratedColumn() 8 | id!: number; 9 | 10 | @Column({ type: String }) 11 | name!: string; 12 | 13 | } 14 | -------------------------------------------------------------------------------- /test/functional/table-inheritance/single-table/non-virtual-discriminator-column/entity/Employee.ts: -------------------------------------------------------------------------------- 1 | import {Column} from "../../../../../../src/decorator/columns/Column.ts"; 2 | import {ChildEntity} from "../../../../../../src/decorator/entity/ChildEntity.ts"; 3 | import {Person} from "./Person.ts"; 4 | 5 | @ChildEntity("employee-type") 6 | export class Employee extends Person { 7 | 8 | @Column({ type: Number }) 9 | salary!: number; 10 | 11 | } 12 | -------------------------------------------------------------------------------- /test/functional/table-inheritance/single-table/non-virtual-discriminator-column/entity/Student.ts: -------------------------------------------------------------------------------- 1 | import {Column} from "../../../../../../src/decorator/columns/Column.ts"; 2 | import {ChildEntity} from "../../../../../../src/decorator/entity/ChildEntity.ts"; 3 | import {Person} from "./Person.ts"; 4 | 5 | @ChildEntity("student-type") 6 | export class Student extends Person { 7 | 8 | @Column({ type: String }) 9 | faculty!: string; 10 | 11 | } 12 | -------------------------------------------------------------------------------- /test/github-issues/1147/entity/Post.ts: -------------------------------------------------------------------------------- 1 | import {Entity} from "../../../../src/decorator/entity/Entity.ts"; 2 | import {Column} from "../../../../src/decorator/columns/Column.ts"; 3 | import {PrimaryGeneratedColumn} from "../../../../src/decorator/columns/PrimaryGeneratedColumn.ts"; 4 | 5 | @Entity() 6 | export class Post { 7 | @PrimaryGeneratedColumn() 8 | id!: number; 9 | 10 | @Column({ type: String }) 11 | title!: string; 12 | 13 | } 14 | -------------------------------------------------------------------------------- /test/github-issues/1656/entity/A.ts: -------------------------------------------------------------------------------- 1 | import {Entity} from "../../../../src/decorator/entity/Entity.ts"; 2 | import {PrimaryGeneratedColumn} from "../../../../src/decorator/columns/PrimaryGeneratedColumn.ts"; 3 | import {Column} from "../../../../src/decorator/columns/Column.ts"; 4 | 5 | @Entity() 6 | export class A { 7 | 8 | @PrimaryGeneratedColumn() 9 | id!: number; 10 | 11 | @Column({ type: String }) 12 | name!: string; 13 | 14 | } 15 | -------------------------------------------------------------------------------- /test/github-issues/1656/entity/B.ts: -------------------------------------------------------------------------------- 1 | import {Entity} from "../../../../src/decorator/entity/Entity.ts"; 2 | import {PrimaryGeneratedColumn} from "../../../../src/decorator/columns/PrimaryGeneratedColumn.ts"; 3 | import {Column} from "../../../../src/decorator/columns/Column.ts"; 4 | 5 | @Entity() 6 | export class B { 7 | 8 | @PrimaryGeneratedColumn() 9 | id!: number; 10 | 11 | @Column({ type: String }) 12 | name!: string; 13 | 14 | } 15 | -------------------------------------------------------------------------------- /test/github-issues/1656/entity/C.ts: -------------------------------------------------------------------------------- 1 | import {Entity} from "../../../../src/decorator/entity/Entity.ts"; 2 | import {PrimaryGeneratedColumn} from "../../../../src/decorator/columns/PrimaryGeneratedColumn.ts"; 3 | import {Column} from "../../../../src/decorator/columns/Column.ts"; 4 | 5 | @Entity() 6 | export class C { 7 | 8 | @PrimaryGeneratedColumn() 9 | id!: number; 10 | 11 | @Column({ type: String }) 12 | name!: string; 13 | 14 | } 15 | -------------------------------------------------------------------------------- /test/github-issues/1720/entity/Category.ts: -------------------------------------------------------------------------------- 1 | import {AfterLoad, Column, Entity, PrimaryGeneratedColumn} from "../../../../src/index.ts"; 2 | 3 | @Entity() 4 | export class Category { 5 | 6 | @PrimaryGeneratedColumn() 7 | id!: number; 8 | 9 | @Column({ type: String }) 10 | name!: string; 11 | 12 | loaded: boolean = false; 13 | 14 | @AfterLoad() 15 | printMessage() { 16 | this.loaded = true; 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /test/github-issues/1883/entity/Post.ts: -------------------------------------------------------------------------------- 1 | import {Entity, PrimaryGeneratedColumn} from "../../../../src/index.ts"; 2 | import {FruitEnum} from "../enum/FruitEnum.ts"; 3 | import {Column} from "../../../../src/decorator/columns/Column.ts"; 4 | 5 | @Entity() 6 | export class Post { 7 | 8 | @PrimaryGeneratedColumn() 9 | id!: number; 10 | 11 | @Column("enum", { enum: FruitEnum, default: FruitEnum.Apple }) 12 | fruit!: FruitEnum; 13 | 14 | } 15 | -------------------------------------------------------------------------------- /test/github-issues/2251/entity/Bar.ts: -------------------------------------------------------------------------------- 1 | import { Column, ManyToOne, PrimaryGeneratedColumn } from "../../../../src/index.ts"; 2 | import { Entity } from "../../../../src/decorator/entity/Entity.ts"; 3 | import { Foo } from "./Foo.ts"; 4 | 5 | @Entity() 6 | export class Bar { 7 | @PrimaryGeneratedColumn() id!: number; 8 | 9 | @Column({ type: String }) description!: string; 10 | 11 | @ManyToOne(type => Foo, foo => foo.bars) 12 | foo?: Foo; 13 | } 14 | -------------------------------------------------------------------------------- /test/github-issues/3694/entity/Post.ts: -------------------------------------------------------------------------------- 1 | import {Entity, PrimaryGeneratedColumn} from "../../../../src/index.ts"; 2 | import {FruitEnum} from "../enum/FruitEnum.ts"; 3 | import {Column} from "../../../../src/decorator/columns/Column.ts"; 4 | 5 | @Entity() 6 | export class Post { 7 | 8 | @PrimaryGeneratedColumn() 9 | id!: number; 10 | 11 | @Column("enum", { enum: FruitEnum, default: FruitEnum.Apple }) 12 | fruit!: FruitEnum; 13 | 14 | } 15 | -------------------------------------------------------------------------------- /test/github-issues/3828/entity/Entity.ts: -------------------------------------------------------------------------------- 1 | import { Column, Entity, PrimaryGeneratedColumn } from "../../../../src/index.ts"; 2 | 3 | enum MyEntityEnum { 4 | Something = "SOMETHING", 5 | SomethingElse = "SOMETHING_ELSE" 6 | } 7 | 8 | @Entity({ name: "MyEntity" }) 9 | export class MyEntity { 10 | @PrimaryGeneratedColumn("uuid") 11 | id!: number; 12 | 13 | @Column("enum", { enum: MyEntityEnum }) 14 | myColumn!: MyEntityEnum; 15 | } 16 | -------------------------------------------------------------------------------- /test/github-issues/4701/migration/1571426391120-ExampleMigrationThree.ts: -------------------------------------------------------------------------------- 1 | import { MigrationInterface } from "../../../../src/migration/MigrationInterface.ts"; 2 | import { QueryRunner } from "../../../../src/query-runner/QueryRunner.ts"; 3 | 4 | export class ExampleMigrationThree1571426391120 implements MigrationInterface { 5 | public async up(queryRunner: QueryRunner): Promise {} 6 | public async down(queryRunner: QueryRunner): Promise {} 7 | } 8 | -------------------------------------------------------------------------------- /sample/sample3-many-to-one/entity/PostAuthor.ts: -------------------------------------------------------------------------------- 1 | import {Column, Entity, OneToMany, PrimaryGeneratedColumn} from "../../../src/index.ts"; 2 | import {Post} from "./Post.ts"; 3 | 4 | @Entity("sample3_post_author") 5 | export class PostAuthor { 6 | 7 | @PrimaryGeneratedColumn() 8 | id: number; 9 | 10 | @Column({ type: String }) 11 | name: string; 12 | 13 | @OneToMany(type => Post, post => post.author) 14 | posts: Post[]; 15 | 16 | } 17 | -------------------------------------------------------------------------------- /sample/sample4-many-to-many/entity/PostImage.ts: -------------------------------------------------------------------------------- 1 | import {Column, Entity, ManyToMany, PrimaryGeneratedColumn} from "../../../src/index.ts"; 2 | import {Post} from "./Post.ts"; 3 | 4 | @Entity("sample4_post_image") 5 | export class PostImage { 6 | 7 | @PrimaryGeneratedColumn() 8 | id: number; 9 | 10 | @Column({ type: String }) 11 | url: string; 12 | 13 | @ManyToMany(type => Post, post => post.images) 14 | posts: Post[]; 15 | 16 | } 17 | -------------------------------------------------------------------------------- /src/metadata-args/types/ColumnMode.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Kinda type of the column. Not a type in the database, but locally used type to determine what kind of column 3 | * we are working with. 4 | * For example, "primary" means that it will be a primary column, or "createDate" means that it will create a create 5 | * date column. 6 | */ 7 | export type ColumnMode = "regular"|"virtual"|"createDate"|"updateDate"|"version"|"treeChildrenCount"|"treeLevel"|"objectId"|"array"; 8 | -------------------------------------------------------------------------------- /test/functional/deferrable/entity/Company.ts: -------------------------------------------------------------------------------- 1 | import {Entity} from "../../../../src/decorator/entity/Entity.ts"; 2 | import {Column} from "../../../../src/decorator/columns/Column.ts"; 3 | import {PrimaryColumn} from "../../../../src/decorator/columns/PrimaryColumn.ts"; 4 | 5 | @Entity() 6 | export class Company { 7 | 8 | @PrimaryColumn({ type: Number }) 9 | id!: number; 10 | 11 | @Column({ type: String }) 12 | name?: string; 13 | 14 | } 15 | -------------------------------------------------------------------------------- /test/github-issues/401/entity/Group.ts: -------------------------------------------------------------------------------- 1 | import {Entity} from "../../../../src/decorator/entity/Entity.ts"; 2 | import {Column} from "../../../../src/decorator/columns/Column.ts"; 3 | import {PrimaryGeneratedColumn} from "../../../../src/decorator/columns/PrimaryGeneratedColumn.ts"; 4 | 5 | @Entity() 6 | export class Group { 7 | 8 | @PrimaryGeneratedColumn() 9 | id!: number; 10 | 11 | @Column({ type: String }) 12 | name!: string; 13 | 14 | } 15 | -------------------------------------------------------------------------------- /test/github-issues/660/entity/User.ts: -------------------------------------------------------------------------------- 1 | import {Entity} from "../../../../src/decorator/entity/Entity.ts"; 2 | import {PrimaryGeneratedColumn} from "../../../../src/decorator/columns/PrimaryGeneratedColumn.ts"; 3 | import {Column} from "../../../../src/decorator/columns/Column.ts"; 4 | 5 | @Entity() 6 | export class User { 7 | 8 | @PrimaryGeneratedColumn() 9 | id!: number; 10 | 11 | @Column({ type: String }) 12 | name!: string; 13 | 14 | } 15 | -------------------------------------------------------------------------------- /test/github-issues/704/entity/User.ts: -------------------------------------------------------------------------------- 1 | import {Entity} from "../../../../src/decorator/entity/Entity.ts"; 2 | import {PrimaryGeneratedColumn} from "../../../../src/decorator/columns/PrimaryGeneratedColumn.ts"; 3 | import {Column} from "../../../../src/decorator/columns/Column.ts"; 4 | 5 | @Entity() 6 | export class User { 7 | 8 | @PrimaryGeneratedColumn() 9 | id!: number; 10 | 11 | @Column({ type: String }) 12 | email!: string; 13 | 14 | } 15 | -------------------------------------------------------------------------------- /test/github-issues/778/entity/Post.ts: -------------------------------------------------------------------------------- 1 | import {Entity} from "../../../../src/decorator/entity/Entity.ts"; 2 | import {Column} from "../../../../src/decorator/columns/Column.ts"; 3 | import {PrimaryGeneratedColumn} from "../../../../src/decorator/columns/PrimaryGeneratedColumn.ts"; 4 | 5 | @Entity() 6 | export class Post { 7 | 8 | @PrimaryGeneratedColumn() 9 | id!: number; 10 | 11 | @Column({ type: String }) 12 | name!: string; 13 | 14 | } 15 | -------------------------------------------------------------------------------- /test/github-issues/80/entity/Post.ts: -------------------------------------------------------------------------------- 1 | import {Entity} from "../../../../src/decorator/entity/Entity.ts"; 2 | import {PrimaryGeneratedColumn} from "../../../../src/decorator/columns/PrimaryGeneratedColumn.ts"; 3 | import {Column} from "../../../../src/decorator/columns/Column.ts"; 4 | 5 | @Entity() 6 | export class Post { 7 | 8 | @PrimaryGeneratedColumn() 9 | id!: number; 10 | 11 | @Column({ type: String }) 12 | title!: string; 13 | 14 | } 15 | -------------------------------------------------------------------------------- /sample/sample4-many-to-many/entity/PostAuthor.ts: -------------------------------------------------------------------------------- 1 | import {Column, Entity, ManyToMany, PrimaryGeneratedColumn} from "../../../src/index.ts"; 2 | import {Post} from "./Post.ts"; 3 | 4 | @Entity("sample4_post_author") 5 | export class PostAuthor { 6 | 7 | @PrimaryGeneratedColumn() 8 | id: number; 9 | 10 | @Column({ type: String }) 11 | name: string; 12 | 13 | @ManyToMany(type => Post, post => post.authors) 14 | posts: Post[]; 15 | 16 | } 17 | -------------------------------------------------------------------------------- /test/functional/connection/entity/Post.ts: -------------------------------------------------------------------------------- 1 | import {Entity} from "../../../../src/decorator/entity/Entity.ts"; 2 | import {PrimaryGeneratedColumn} from "../../../../src/decorator/columns/PrimaryGeneratedColumn.ts"; 3 | import {Column} from "../../../../src/decorator/columns/Column.ts"; 4 | 5 | @Entity() 6 | export class Post { 7 | 8 | @PrimaryGeneratedColumn() 9 | id!: number; 10 | 11 | @Column({ type: String }) 12 | title!: string; 13 | 14 | } 15 | -------------------------------------------------------------------------------- /test/functional/query-builder/relation-id/many-to-one/embedded-with-multiple-pk/entity/Category.ts: -------------------------------------------------------------------------------- 1 | import {Entity} from "../../../../../../../src/decorator/entity/Entity.ts"; 2 | import {PrimaryColumn} from "../../../../../../../src/decorator/columns/PrimaryColumn.ts"; 3 | 4 | @Entity() 5 | export class Category { 6 | 7 | @PrimaryColumn({ type: Number }) 8 | id!: number; 9 | 10 | @PrimaryColumn({ type: String }) 11 | name!: string; 12 | 13 | } 14 | -------------------------------------------------------------------------------- /test/functional/query-builder/relation-id/many-to-one/embedded/entity/Post.ts: -------------------------------------------------------------------------------- 1 | import {Entity} from "../../../../../../../src/decorator/entity/Entity.ts"; 2 | import {Column} from "../../../../../../../src/decorator/columns/Column.ts"; 3 | import {Counters} from "./Counters.ts"; 4 | 5 | @Entity() 6 | export class Post { 7 | 8 | @Column({ type: String }) 9 | title!: string; 10 | 11 | @Column(() => Counters) 12 | counters!: Counters; 13 | 14 | } 15 | -------------------------------------------------------------------------------- /test/functional/query-builder/relation-id/one-to-many/embedded/entity/Post.ts: -------------------------------------------------------------------------------- 1 | import {Entity} from "../../../../../../../src/decorator/entity/Entity.ts"; 2 | import {Column} from "../../../../../../../src/decorator/columns/Column.ts"; 3 | import {Counters} from "./Counters.ts"; 4 | 5 | @Entity() 6 | export class Post { 7 | 8 | @Column({ type: String }) 9 | title!: string; 10 | 11 | @Column(() => Counters) 12 | counters!: Counters; 13 | 14 | } 15 | -------------------------------------------------------------------------------- /test/functional/query-builder/relation-id/one-to-one/embedded-with-multiple-pk/entity/Category.ts: -------------------------------------------------------------------------------- 1 | import {Entity} from "../../../../../../../src/decorator/entity/Entity.ts"; 2 | import {PrimaryColumn} from "../../../../../../../src/decorator/columns/PrimaryColumn.ts"; 3 | 4 | @Entity() 5 | export class Category { 6 | 7 | @PrimaryColumn({ type: Number }) 8 | id!: number; 9 | 10 | @PrimaryColumn({ type: String }) 11 | name!: string; 12 | 13 | } 14 | -------------------------------------------------------------------------------- /test/functional/query-builder/relation-id/one-to-one/embedded/entity/Post.ts: -------------------------------------------------------------------------------- 1 | import {Entity} from "../../../../../../../src/decorator/entity/Entity.ts"; 2 | import {Column} from "../../../../../../../src/decorator/columns/Column.ts"; 3 | import {Counters} from "./Counters.ts"; 4 | 5 | @Entity() 6 | export class Post { 7 | 8 | @Column({ type: String }) 9 | title!: string; 10 | 11 | @Column(() => Counters) 12 | counters!: Counters; 13 | 14 | } 15 | -------------------------------------------------------------------------------- /test/github-issues/108/entity/User.ts: -------------------------------------------------------------------------------- 1 | import {Entity} from "../../../../src/decorator/entity/Entity.ts"; 2 | import {PrimaryGeneratedColumn} from "../../../../src/decorator/columns/PrimaryGeneratedColumn.ts"; 3 | import {Column} from "../../../../src/decorator/columns/Column.ts"; 4 | 5 | @Entity() 6 | export class User { 7 | 8 | @PrimaryGeneratedColumn() 9 | id!: number; 10 | 11 | @Column({ unique: true, type: String }) 12 | name!: string; 13 | } 14 | -------------------------------------------------------------------------------- /test/github-issues/151/entity/Category.ts: -------------------------------------------------------------------------------- 1 | import {Entity} from "../../../../src/decorator/entity/Entity.ts"; 2 | import {PrimaryGeneratedColumn} from "../../../../src/decorator/columns/PrimaryGeneratedColumn.ts"; 3 | import {Column} from "../../../../src/decorator/columns/Column.ts"; 4 | 5 | @Entity() 6 | export class Category { 7 | 8 | @PrimaryGeneratedColumn() 9 | id!: number; 10 | 11 | @Column({ type: String }) 12 | name!: string; 13 | 14 | } 15 | -------------------------------------------------------------------------------- /test/github-issues/190/entity/Category.ts: -------------------------------------------------------------------------------- 1 | import {Entity} from "../../../../src/decorator/entity/Entity.ts"; 2 | import {PrimaryGeneratedColumn} from "../../../../src/decorator/columns/PrimaryGeneratedColumn.ts"; 3 | import {Column} from "../../../../src/decorator/columns/Column.ts"; 4 | 5 | @Entity() 6 | export class Category { 7 | 8 | @PrimaryGeneratedColumn() 9 | id!: number; 10 | 11 | @Column({ type: String }) 12 | name!: string; 13 | 14 | } 15 | -------------------------------------------------------------------------------- /test/github-issues/215/entity/Author.ts: -------------------------------------------------------------------------------- 1 | import {Entity} from "../../../../src/decorator/entity/Entity.ts"; 2 | import {PrimaryGeneratedColumn} from "../../../../src/decorator/columns/PrimaryGeneratedColumn.ts"; 3 | import {Column} from "../../../../src/decorator/columns/Column.ts"; 4 | 5 | @Entity() 6 | export class Author { 7 | 8 | @PrimaryGeneratedColumn() 9 | id!: number; 10 | 11 | @Column({ type: String }) 12 | name!: string; 13 | 14 | } 15 | -------------------------------------------------------------------------------- /test/github-issues/2364/entity/dummy.ts: -------------------------------------------------------------------------------- 1 | import {Column} from "../../../../src/decorator/columns/Column.ts"; 2 | import {Entity} from "../../../../src/decorator/entity/Entity.ts"; 3 | 4 | @Entity() 5 | export class Dummy { 6 | @Column("integer", { 7 | generated: true, 8 | nullable: false, 9 | primary: true, 10 | }) 11 | id!: number; 12 | 13 | @Column({ type: String, default: "name" }) 14 | name!: string; 15 | } 16 | 17 | -------------------------------------------------------------------------------- /test/github-issues/2965/entity/note.ts: -------------------------------------------------------------------------------- 1 | import { Entity, Column, ManyToOne, PrimaryGeneratedColumn } from "../../../../src/index.ts"; 2 | import { Person } from "./person.ts"; 3 | 4 | @Entity() 5 | export class Note { 6 | @PrimaryGeneratedColumn() 7 | public id!: number; 8 | 9 | @Column({ type: String }) 10 | public label!: string; 11 | 12 | @ManyToOne(type => Person, { lazy: true }) 13 | public owner!: Promise | Person; 14 | } 15 | -------------------------------------------------------------------------------- /test/github-issues/3363/entity/Post.ts: -------------------------------------------------------------------------------- 1 | import {Column} from "../../../../src/decorator/columns/Column.ts"; 2 | import {Entity} from "../../../../src/decorator/entity/Entity.ts"; 3 | import { PrimaryGeneratedColumn } from "../../../../src/decorator/columns/PrimaryGeneratedColumn.ts"; 4 | 5 | @Entity() 6 | export class Post { 7 | 8 | @PrimaryGeneratedColumn() 9 | id!: number; 10 | 11 | @Column({ type: String }) 12 | title!: string; 13 | 14 | } 15 | -------------------------------------------------------------------------------- /test/github-issues/3374/entity/Post.ts: -------------------------------------------------------------------------------- 1 | import {Column} from "../../../../src/decorator/columns/Column.ts"; 2 | import {Entity} from "../../../../src/decorator/entity/Entity.ts"; 3 | import {PrimaryGeneratedColumn} from "../../../../src/decorator/columns/PrimaryGeneratedColumn.ts"; 4 | 5 | @Entity() 6 | export class Post { 7 | 8 | @PrimaryGeneratedColumn("uuid") 9 | id!: number; 10 | 11 | @Column({ type: String }) 12 | name!: string; 13 | 14 | } 15 | -------------------------------------------------------------------------------- /test/github-issues/495/entity/User.ts: -------------------------------------------------------------------------------- 1 | import {Entity} from "../../../../src/decorator/entity/Entity.ts"; 2 | import {PrimaryGeneratedColumn} from "../../../../src/decorator/columns/PrimaryGeneratedColumn.ts"; 3 | import {Column} from "../../../../src/decorator/columns/Column.ts"; 4 | 5 | @Entity() 6 | export class User { 7 | 8 | @PrimaryGeneratedColumn() 9 | userId!: number; 10 | 11 | @Column({ type: String }) 12 | name!: string; 13 | 14 | } 15 | -------------------------------------------------------------------------------- /sample/sample10-mixed/entity/Chapter.ts: -------------------------------------------------------------------------------- 1 | import {Column, Entity, OneToMany, PrimaryGeneratedColumn} from "../../../src/index"; 2 | import {PostDetails} from "./PostDetails"; 3 | 4 | @Entity("sample10_chapter") 5 | export class Chapter { 6 | 7 | @PrimaryGeneratedColumn() 8 | id: number; 9 | 10 | @Column() 11 | about: string; 12 | 13 | @OneToMany(type => PostDetails, postDetails => postDetails.chapter) 14 | postDetails: PostDetails[]; 15 | 16 | } -------------------------------------------------------------------------------- /sample/sample2-one-to-one/entity/PostMetadata.ts: -------------------------------------------------------------------------------- 1 | import {Column, Entity, OneToOne, PrimaryGeneratedColumn} from "../../../src/index.ts"; 2 | import {Post} from "./Post.ts"; 3 | 4 | @Entity("sample2_post_metadata") 5 | export class PostMetadata { 6 | 7 | @PrimaryGeneratedColumn() 8 | id: number; 9 | 10 | @Column({ type: String }) 11 | description: string; 12 | 13 | @OneToOne(type => Post, post => post.metadata) 14 | post: Post; 15 | 16 | } 17 | -------------------------------------------------------------------------------- /src/error/LockNotSupportedOnGivenDriverError.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Thrown when selected sql driver does not supports locking. 3 | */ 4 | export class LockNotSupportedOnGivenDriverError extends Error { 5 | name = "LockNotSupportedOnGivenDriverError"; 6 | 7 | constructor() { 8 | super(); 9 | Object.setPrototypeOf(this, LockNotSupportedOnGivenDriverError.prototype); 10 | this.message = `Locking not supported on given driver.`; 11 | } 12 | 13 | } -------------------------------------------------------------------------------- /test/functional/metadata-builder/metadata-args-storage/entity/Post.ts: -------------------------------------------------------------------------------- 1 | import {Entity} from "../../../../../src/decorator/entity/Entity.ts"; 2 | import {Column} from "../../../../../src/decorator/columns/Column.ts"; 3 | import {ContentModule} from "./ContentModule.ts"; 4 | 5 | @Entity() 6 | export class Post extends ContentModule { 7 | 8 | @Column({ type: String }) 9 | title!: string; 10 | 11 | @Column({ type: String }) 12 | text!: string; 13 | 14 | } 15 | -------------------------------------------------------------------------------- /test/functional/query-runner/entity/Faculty.ts: -------------------------------------------------------------------------------- 1 | import {Entity} from "../../../../src/decorator/entity/Entity.ts"; 2 | import {Column} from "../../../../src/decorator/columns/Column.ts"; 3 | import {PrimaryGeneratedColumn} from "../../../../src/decorator/columns/PrimaryGeneratedColumn.ts"; 4 | 5 | @Entity() 6 | export class Faculty { 7 | 8 | @PrimaryGeneratedColumn() 9 | id!: number; 10 | 11 | @Column({ type: String }) 12 | name!: string; 13 | 14 | } 15 | -------------------------------------------------------------------------------- /test/github-issues/1014/entity/TestEntity.ts: -------------------------------------------------------------------------------- 1 | import {Entity} from "../../../../src/decorator/entity/Entity.ts"; 2 | import {Column} from "../../../../src/decorator/columns/Column.ts"; 3 | import {PrimaryGeneratedColumn} from "../../../../src/decorator/columns/PrimaryGeneratedColumn.ts"; 4 | 5 | @Entity() 6 | export class TestEntity { 7 | 8 | @PrimaryGeneratedColumn() 9 | id!: number; 10 | 11 | @Column({ type: String }) 12 | name!: string; 13 | 14 | } 15 | -------------------------------------------------------------------------------- /test/github-issues/1504/entity/TestEntity4.ts: -------------------------------------------------------------------------------- 1 | import {Column, Entity, ManyToOne, PrimaryGeneratedColumn} from "../../../../src/index.ts"; 2 | import {TestEntity3} from "./TestEntity3.ts"; 3 | 4 | @Entity() 5 | export class TestEntity4 { 6 | 7 | @PrimaryGeneratedColumn() 8 | id!: number; 9 | 10 | @Column({ type: String }) 11 | name!: string; 12 | 13 | @ManyToOne(t => TestEntity3, entity3 => entity3.Entity4) 14 | Entity3!: TestEntity3; 15 | } 16 | -------------------------------------------------------------------------------- /test/github-issues/1545/entity/MainModel.ts: -------------------------------------------------------------------------------- 1 | import { Entity, PrimaryGeneratedColumn, OneToMany } from "../../../../src/index.ts"; 2 | import { DataModel } from "./DataModel.ts"; 3 | 4 | @Entity() 5 | export class MainModel { 6 | @PrimaryGeneratedColumn() 7 | id!: number; 8 | 9 | @OneToMany( 10 | type => DataModel, 11 | dataModel => dataModel.main, 12 | {cascade: true, eager: true} 13 | ) 14 | dataModel!: DataModel[]; 15 | } 16 | -------------------------------------------------------------------------------- /test/github-issues/1754/entity/tipo-cliente.ts: -------------------------------------------------------------------------------- 1 | import { Entity, PrimaryGeneratedColumn, Column, OneToMany } from "../../../../src/index.ts"; 2 | import { Cliente } from "./cliente.ts"; 3 | 4 | @Entity() 5 | export class TipoCliente { 6 | 7 | @PrimaryGeneratedColumn() 8 | id!: number; 9 | 10 | @Column({type: String, name: "tipo"}) 11 | descricao!: string; 12 | 13 | @OneToMany(() => Cliente, c => c.tipo) 14 | clientes!: Cliente[]; 15 | 16 | } 17 | -------------------------------------------------------------------------------- /test/github-issues/2006/entity/User.ts: -------------------------------------------------------------------------------- 1 | import {Column, Entity, PrimaryGeneratedColumn} from "../../../../src/index.ts"; 2 | 3 | @Entity() 4 | export class User { 5 | 6 | @PrimaryGeneratedColumn() 7 | id!: number; 8 | 9 | @Column("varchar", { nullable: true }) 10 | token: string | null = null; 11 | 12 | @Column({ 13 | type: "tinyint", 14 | default: 0, 15 | width: 1 16 | }) 17 | dnd: boolean = false; 18 | 19 | } 20 | -------------------------------------------------------------------------------- /test/github-issues/2364/entity/dummy2.ts: -------------------------------------------------------------------------------- 1 | import {Entity} from "../../../../src/decorator/entity/Entity.ts"; 2 | import {Column, PrimaryColumn} from "../../../../src/index.ts"; 3 | 4 | @Entity() 5 | export class Dummy2 { 6 | @PrimaryColumn("integer", { 7 | generated: true, 8 | nullable: false, 9 | primary: true, 10 | }) 11 | id!: number; 12 | 13 | @Column({ type: String, default: "name" }) 14 | name!: string; 15 | } 16 | 17 | -------------------------------------------------------------------------------- /test/github-issues/3350/entity/Category.ts: -------------------------------------------------------------------------------- 1 | import {Column} from "../../../../src/decorator/columns/Column.ts"; 2 | import {PrimaryGeneratedColumn} from "../../../../src/decorator/columns/PrimaryGeneratedColumn.ts"; 3 | import {Entity} from "../../../../src/decorator/entity/Entity.ts"; 4 | 5 | @Entity() 6 | export class Category { 7 | 8 | @PrimaryGeneratedColumn() 9 | id!: number; 10 | 11 | @Column({ type: String }) 12 | name!: string; 13 | 14 | } 15 | -------------------------------------------------------------------------------- /test/github-issues/3352/entity/Post.ts: -------------------------------------------------------------------------------- 1 | import {Column} from "../../../../src/decorator/columns/Column.ts"; 2 | import {PrimaryColumn} from "../../../../src/decorator/columns/PrimaryColumn.ts"; 3 | import {Entity} from "../../../../src/decorator/entity/Entity.ts"; 4 | 5 | @Entity() 6 | export class Post { 7 | 8 | @PrimaryColumn({ type: Number }) 9 | id!: number; 10 | 11 | @Column({ 12 | type: "text", 13 | }) 14 | text!: string; 15 | 16 | } 17 | -------------------------------------------------------------------------------- /test/github-issues/3496/entity/Post.ts: -------------------------------------------------------------------------------- 1 | import {Entity} from "../../../../src/index.ts"; 2 | import {PrimaryGeneratedColumn} from "../../../../src/index.ts"; 3 | import {Column, VersionColumn} from "../../../../src/index.ts"; 4 | 5 | @Entity() 6 | export class Post { 7 | @PrimaryGeneratedColumn() 8 | id!: number; 9 | 10 | @VersionColumn({ type: Number }) 11 | version!: number; 12 | 13 | @Column({ type: "jsonb" }) 14 | problems!: object; 15 | } 16 | -------------------------------------------------------------------------------- /test/github-issues/3588/entity/mysql.ts: -------------------------------------------------------------------------------- 1 | import { Entity, PrimaryGeneratedColumn, Column } from "../../../../src/index.ts"; 2 | 3 | @Entity({ name: "Session" }) 4 | export class Session { 5 | 6 | @PrimaryGeneratedColumn() 7 | id?: number; 8 | 9 | @Column({ 10 | type: "timestamp", 11 | precision: 3, 12 | default: () => "CURRENT_TIMESTAMP(3)", 13 | onUpdate: "CURRENT_TIMESTAMP(3)", 14 | }) 15 | ts!: Date; 16 | 17 | } 18 | -------------------------------------------------------------------------------- /test/github-issues/463/entity/Post.ts: -------------------------------------------------------------------------------- 1 | import {Entity} from "../../../../src/decorator/entity/Entity.ts"; 2 | import {Column} from "../../../../src/decorator/columns/Column.ts"; 3 | import {PrimaryGeneratedColumn} from "../../../../src/decorator/columns/PrimaryGeneratedColumn.ts"; 4 | 5 | @Entity() 6 | export class Post { 7 | 8 | @PrimaryGeneratedColumn() 9 | identifier!: number; 10 | 11 | @Column("simple-array") 12 | names!: string[]; 13 | 14 | } 15 | -------------------------------------------------------------------------------- /test/github-issues/929/entity/TestEntity.ts: -------------------------------------------------------------------------------- 1 | import {Entity} from "../../../../src/decorator/entity/Entity.ts"; 2 | import {PrimaryGeneratedColumn} from "../../../../src/decorator/columns/PrimaryGeneratedColumn.ts"; 3 | import {Column} from "../../../../src/decorator/columns/Column.ts"; 4 | 5 | @Entity() 6 | export class TestEntity { 7 | 8 | @PrimaryGeneratedColumn() 9 | id!: number; 10 | 11 | @Column({ type: String }) 12 | name!: string; 13 | 14 | } 15 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | # EditorConfig is awesome: http://EditorConfig.org 2 | 3 | # top-most EditorConfig file 4 | root = true 5 | 6 | # Unix-style newlines with a newline ending every file 7 | [*] 8 | end_of_line = lf 9 | insert_final_newline = true 10 | trim_trailing_whitespace = true 11 | charset = utf-8 12 | indent_style = space 13 | indent_size = 4 14 | 15 | # Matches the exact files either *.json or *.yml 16 | [*.{json,yml}] 17 | indent_style = space 18 | indent_size = 2 19 | -------------------------------------------------------------------------------- /sample/sample17-versioning/entity/Post.ts: -------------------------------------------------------------------------------- 1 | import {Column, Entity, PrimaryGeneratedColumn} from "../../../src/index"; 2 | import {VersionColumn} from "../../../src/decorator/columns/VersionColumn"; 3 | 4 | @Entity("sample17_post") 5 | export class Post { 6 | 7 | @PrimaryGeneratedColumn() 8 | id: number; 9 | 10 | @Column() 11 | title: string; 12 | 13 | @Column() 14 | text: string; 15 | 16 | @VersionColumn() 17 | version: number; 18 | 19 | } -------------------------------------------------------------------------------- /sample/sample3-many-to-one/entity/PostMetadata.ts: -------------------------------------------------------------------------------- 1 | import {Column, Entity, OneToMany, PrimaryGeneratedColumn} from "../../../src/index.ts"; 2 | import {Post} from "./Post.ts"; 3 | 4 | @Entity("sample3_post_metadata") 5 | export class PostMetadata { 6 | 7 | @PrimaryGeneratedColumn() 8 | id: number; 9 | 10 | @Column({ type: String }) 11 | description: string; 12 | 13 | @OneToMany(type => Post, post => post.metadata) 14 | posts: Post[]; 15 | 16 | } 17 | -------------------------------------------------------------------------------- /src/error/PersistedEntityNotFoundError.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Thrown . Theoretically can't be thrown. 3 | */ 4 | export class PersistedEntityNotFoundError extends Error { 5 | name = "PersistedEntityNotFoundError"; 6 | 7 | constructor() { 8 | super(); 9 | Object.setPrototypeOf(this, PersistedEntityNotFoundError.prototype); 10 | this.message = `Internal error. Persisted entity was not found in the list of prepared operated entities.`; 11 | } 12 | 13 | } -------------------------------------------------------------------------------- /test/functional/driver/convert-to-entity/entity/Post.ts: -------------------------------------------------------------------------------- 1 | import {Entity} from "../../../../../src/decorator/entity/Entity.ts"; 2 | import {Column} from "../../../../../src/decorator/columns/Column.ts"; 3 | import {PrimaryColumn} from "../../../../../src/decorator/columns/PrimaryColumn.ts"; 4 | 5 | @Entity() 6 | export class Post { 7 | 8 | @PrimaryColumn("int") 9 | id!: number; 10 | 11 | @Column({nullable: true, type: Boolean}) 12 | isNew!: boolean; 13 | } 14 | -------------------------------------------------------------------------------- /test/functional/repository/basic-methods/schema/user.js: -------------------------------------------------------------------------------- 1 | export default { 2 | "name": "User", 3 | "table": { 4 | "name": "user" 5 | }, 6 | "columns": { 7 | "id": { 8 | "type": "int", 9 | "primary": true, 10 | "generated": true 11 | }, 12 | "firstName": { 13 | "type": "varchar", 14 | "nullable": false 15 | }, 16 | "secondName": { 17 | "type": "varchar", 18 | "nullable": false 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /test/functional/schema-builder/entity/Faculty.ts: -------------------------------------------------------------------------------- 1 | import {Entity} from "../../../../src/decorator/entity/Entity.ts"; 2 | import {Column} from "../../../../src/decorator/columns/Column.ts"; 3 | import {PrimaryGeneratedColumn} from "../../../../src/decorator/columns/PrimaryGeneratedColumn.ts"; 4 | 5 | @Entity() 6 | export class Faculty { 7 | 8 | @PrimaryGeneratedColumn() 9 | id!: number; 10 | 11 | @Column({ type: String }) 12 | name!: string; 13 | 14 | } 15 | -------------------------------------------------------------------------------- /test/functional/schema-builder/entity/Question.ts: -------------------------------------------------------------------------------- 1 | import {Entity} from "../../../../src/decorator/entity/Entity.ts"; 2 | import {Column} from "../../../../src/decorator/columns/Column.ts"; 3 | import {PrimaryGeneratedColumn} from "../../../../src/decorator/columns/PrimaryGeneratedColumn.ts"; 4 | 5 | @Entity() 6 | export class Question { 7 | 8 | @PrimaryGeneratedColumn() 9 | id!: number; 10 | 11 | @Column({ type: String }) 12 | name!: string; 13 | 14 | } 15 | -------------------------------------------------------------------------------- /test/github-issues/108/entity/Project.ts: -------------------------------------------------------------------------------- 1 | import {Entity} from "../../../../src/decorator/entity/Entity.ts"; 2 | import {PrimaryGeneratedColumn} from "../../../../src/decorator/columns/PrimaryGeneratedColumn.ts"; 3 | import {Column} from "../../../../src/decorator/columns/Column.ts"; 4 | 5 | @Entity() 6 | export class Project { 7 | 8 | @PrimaryGeneratedColumn() 9 | id!: number; 10 | 11 | @Column({ unique: true, type: String }) 12 | name!: string; 13 | } 14 | -------------------------------------------------------------------------------- /test/github-issues/1178/entity/Post.ts: -------------------------------------------------------------------------------- 1 | import {Column, Entity, PrimaryGeneratedColumn} from "../../../../src/index.ts"; 2 | import {User} from "./User.ts"; 3 | import {ManyToOne} from "../../../../src/decorator/relations/ManyToOne.ts"; 4 | 5 | @Entity() 6 | export class Post { 7 | 8 | @PrimaryGeneratedColumn() 9 | id!: number; 10 | 11 | @Column({ type: String }) 12 | name!: string; 13 | 14 | @ManyToOne(type => User) 15 | user!: User; 16 | 17 | } 18 | -------------------------------------------------------------------------------- /test/github-issues/1581/entity/User.ts: -------------------------------------------------------------------------------- 1 | import {Column, Entity, OneToMany, PrimaryGeneratedColumn} from "../../../../src/index.ts"; 2 | import {Order} from "./Order.ts"; 3 | 4 | @Entity() 5 | export class User { 6 | 7 | @PrimaryGeneratedColumn() 8 | id!: number; 9 | 10 | @Column({ type: String, unique: true }) 11 | email!: string; 12 | 13 | @OneToMany(type => Order, recurringOrder => recurringOrder.user) 14 | recurringOrders!: Order[]; 15 | 16 | } 17 | -------------------------------------------------------------------------------- /test/github-issues/215/entity/Abbreviation.ts: -------------------------------------------------------------------------------- 1 | import {Entity} from "../../../../src/decorator/entity/Entity.ts"; 2 | import {PrimaryGeneratedColumn} from "../../../../src/decorator/columns/PrimaryGeneratedColumn.ts"; 3 | import {Column} from "../../../../src/decorator/columns/Column.ts"; 4 | 5 | @Entity() 6 | export class Abbreviation { 7 | 8 | @PrimaryGeneratedColumn() 9 | id!: number; 10 | 11 | @Column({ type: String }) 12 | name!: string; 13 | 14 | } 15 | -------------------------------------------------------------------------------- /test/github-issues/2200/entity/Booking.ts: -------------------------------------------------------------------------------- 1 | import {Entity, PrimaryGeneratedColumn, ManyToOne, JoinColumn} from "../../../../src/index.ts"; 2 | import { Contact } from "./Contact.ts"; 3 | 4 | @Entity() 5 | export class Booking { 6 | 7 | @PrimaryGeneratedColumn() 8 | id!: number; 9 | 10 | @ManyToOne(type => Contact, contact => contact.bookings, { eager: true }) 11 | @JoinColumn({ 12 | name: "contact_id", 13 | }) 14 | contact!: Contact; 15 | } 16 | -------------------------------------------------------------------------------- /test/github-issues/3363/entity/Category.ts: -------------------------------------------------------------------------------- 1 | import { PrimaryGeneratedColumn } from "../../../../src/decorator/columns/PrimaryGeneratedColumn.ts"; 2 | import { Column } from "../../../../src/decorator/columns/Column.ts"; 3 | import { Entity } from "../../../../src/decorator/entity/Entity.ts"; 4 | 5 | @Entity() 6 | export class Category { 7 | 8 | @PrimaryGeneratedColumn() 9 | id!: number; 10 | 11 | @Column({ type: String }) 12 | name!: string; 13 | 14 | } 15 | -------------------------------------------------------------------------------- /test/github-issues/4185/entity/Post.ts: -------------------------------------------------------------------------------- 1 | import {PrimaryColumn} from "../../../../src/decorator/columns/PrimaryColumn.ts"; 2 | import {Entity} from "../../../../src/decorator/entity/Entity.ts"; 3 | import {LoadEvent} from "../../../../src/subscriber/event/LoadEvent.ts"; 4 | 5 | @Entity() 6 | export class Post { 7 | @PrimaryColumn({ type: Number }) 8 | id!: number; 9 | 10 | simpleSubscriberSaw?: boolean; 11 | extendedSubscriberSaw?: LoadEvent; 12 | } 13 | -------------------------------------------------------------------------------- /test/other-issues/preventing-injection/entity/Post.ts: -------------------------------------------------------------------------------- 1 | import {Entity} from "../../../../src/decorator/entity/Entity.ts"; 2 | import {PrimaryGeneratedColumn} from "../../../../src/decorator/columns/PrimaryGeneratedColumn.ts"; 3 | import {Column} from "../../../../src/decorator/columns/Column.ts"; 4 | 5 | @Entity() 6 | export class Post { 7 | 8 | @PrimaryGeneratedColumn() 9 | id!: number; 10 | 11 | @Column({ type: String }) 12 | title!: string; 13 | 14 | } 15 | -------------------------------------------------------------------------------- /sample/sample4-many-to-many/entity/PostMetadata.ts: -------------------------------------------------------------------------------- 1 | import {Column, Entity, ManyToMany, PrimaryGeneratedColumn} from "../../../src/index.ts"; 2 | import {Post} from "./Post.ts"; 3 | 4 | @Entity("sample4_post_metadata") 5 | export class PostMetadata { 6 | 7 | @PrimaryGeneratedColumn() 8 | id: number; 9 | 10 | @Column({ type: String }) 11 | description: string; 12 | 13 | @ManyToMany(type => Post, post => post.metadatas) 14 | posts: Post[]; 15 | 16 | } 17 | -------------------------------------------------------------------------------- /src/error/TreeRepositoryNotSupportedError.ts: -------------------------------------------------------------------------------- 1 | import {Driver} from "../driver/Driver.ts"; 2 | 3 | export class TreeRepositoryNotSupportedError extends Error { 4 | name = "TreeRepositoryNotSupportedError"; 5 | 6 | constructor(driver: Driver) { 7 | super(); 8 | Object.setPrototypeOf(this, TreeRepositoryNotSupportedError.prototype); 9 | this.message = `Tree repositories are not supported in ${driver.options.type} driver.`; 10 | } 11 | 12 | } 13 | -------------------------------------------------------------------------------- /src/subscriber/BroadcasterResult.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Broadcaster execution result - promises executed by operations and number of executed listeners and subscribers. 3 | */ 4 | export class BroadcasterResult { 5 | 6 | /** 7 | * Number of executed listeners and subscribers. 8 | */ 9 | count: number = 0; 10 | 11 | /** 12 | * Promises returned by listeners and subscribers which needs to be awaited. 13 | */ 14 | promises: Promise[] = []; 15 | 16 | } -------------------------------------------------------------------------------- /test/functional/query-builder/delete/entity/User.ts: -------------------------------------------------------------------------------- 1 | import {Entity} from "../../../../../src/decorator/entity/Entity.ts"; 2 | import {PrimaryGeneratedColumn} from "../../../../../src/decorator/columns/PrimaryGeneratedColumn.ts"; 3 | import {Column} from "../../../../../src/decorator/columns/Column.ts"; 4 | 5 | @Entity() 6 | export class User { 7 | 8 | @PrimaryGeneratedColumn() 9 | id!: number; 10 | 11 | @Column({ type: String }) 12 | name!: string; 13 | 14 | } 15 | -------------------------------------------------------------------------------- /test/functional/query-builder/distinct-on/entity/User.ts: -------------------------------------------------------------------------------- 1 | import {Entity} from "../../../../../src/decorator/entity/Entity.ts"; 2 | import {PrimaryGeneratedColumn} from "../../../../../src/decorator/columns/PrimaryGeneratedColumn.ts"; 3 | import {Column} from "../../../../../src/decorator/columns/Column.ts"; 4 | 5 | @Entity() 6 | export class User { 7 | 8 | @PrimaryGeneratedColumn() 9 | id!: number; 10 | 11 | @Column({ type: String }) 12 | name!: string; 13 | 14 | } 15 | -------------------------------------------------------------------------------- /test/functional/query-builder/insert/entity/User.ts: -------------------------------------------------------------------------------- 1 | import {Entity} from "../../../../../src/decorator/entity/Entity.ts"; 2 | import {PrimaryGeneratedColumn} from "../../../../../src/decorator/columns/PrimaryGeneratedColumn.ts"; 3 | import {Column} from "../../../../../src/decorator/columns/Column.ts"; 4 | 5 | @Entity() 6 | export class User { 7 | 8 | @PrimaryGeneratedColumn() 9 | id!: number; 10 | 11 | @Column({ type: String }) 12 | name!: string; 13 | 14 | } 15 | -------------------------------------------------------------------------------- /test/functional/query-builder/join/entity/Tag.ts: -------------------------------------------------------------------------------- 1 | import {Entity} from "../../../../../src/decorator/entity/Entity.ts"; 2 | import {PrimaryGeneratedColumn} from "../../../../../src/decorator/columns/PrimaryGeneratedColumn.ts"; 3 | import {Column} from "../../../../../src/decorator/columns/Column.ts"; 4 | 5 | @Entity() 6 | export class Tag { 7 | 8 | @PrimaryGeneratedColumn() 9 | id!: number; 10 | 11 | @Column({ type: String }) 12 | name!: string; 13 | 14 | } 15 | -------------------------------------------------------------------------------- /test/functional/query-builder/join/entity/User.ts: -------------------------------------------------------------------------------- 1 | import {Entity} from "../../../../../src/decorator/entity/Entity.ts"; 2 | import {PrimaryGeneratedColumn} from "../../../../../src/decorator/columns/PrimaryGeneratedColumn.ts"; 3 | import {Column} from "../../../../../src/decorator/columns/Column.ts"; 4 | 5 | @Entity() 6 | export class User { 7 | 8 | @PrimaryGeneratedColumn() 9 | id!: number; 10 | 11 | @Column({ type: String }) 12 | name!: string; 13 | 14 | } 15 | -------------------------------------------------------------------------------- /test/functional/query-runner/entity/Book.ts: -------------------------------------------------------------------------------- 1 | import { PrimaryColumn } from "../../../../src/decorator/columns/PrimaryColumn.ts"; 2 | import { Entity } from "../../../../src/decorator/entity/Entity.ts"; 3 | 4 | @Entity() 5 | export class Book { 6 | 7 | @PrimaryColumn({ type: String }) 8 | ean!: string; 9 | 10 | } 11 | 12 | @Entity({ withoutRowid: true }) 13 | export class Book2 { 14 | 15 | @PrimaryColumn({ type: String }) 16 | ean!: string; 17 | 18 | } 19 | 20 | -------------------------------------------------------------------------------- /test/functional/schema-builder/entity/Album.ts: -------------------------------------------------------------------------------- 1 | import {Entity} from "../../../../src/decorator/entity/Entity.ts"; 2 | import {Column} from "../../../../src/decorator/columns/Column.ts"; 3 | import {PrimaryColumn} from "../../../../src/decorator/columns/PrimaryColumn.ts"; 4 | 5 | @Entity({ synchronize: false }) 6 | export class Album { 7 | 8 | @PrimaryColumn({ type: Number }) 9 | id!: number; 10 | 11 | @Column({ type: String }) 12 | name!: string; 13 | 14 | } 15 | -------------------------------------------------------------------------------- /test/github-issues/1504/entity/TestEntity1.ts: -------------------------------------------------------------------------------- 1 | import {Column, Entity, JoinColumn, OneToOne, PrimaryGeneratedColumn} from "../../../../src/index.ts"; 2 | import {TestEntity2} from "./TestEntity2.ts"; 3 | 4 | @Entity() 5 | export class TestEntity1 { 6 | 7 | @PrimaryGeneratedColumn() 8 | id!: number; 9 | 10 | @Column({ type: String }) name!: string; 11 | 12 | @OneToOne(t => TestEntity2, a => a.Entity1) 13 | @JoinColumn() 14 | Entity2!: TestEntity2; 15 | } 16 | -------------------------------------------------------------------------------- /test/github-issues/2965/entity/person.ts: -------------------------------------------------------------------------------- 1 | import { Entity, Column, OneToMany, PrimaryGeneratedColumn } from "../../../../src/index.ts"; 2 | import { Note } from "./note.ts"; 3 | 4 | @Entity() 5 | export class Person { 6 | @PrimaryGeneratedColumn() 7 | public id!: number; 8 | 9 | @Column({ type: String }) 10 | public name!: string; 11 | 12 | @OneToMany(type => Note, note => note.owner, { lazy: true }) 13 | public notes!: Promise | Note[]; 14 | } 15 | -------------------------------------------------------------------------------- /test/github-issues/4697/entity/config.entity.ts: -------------------------------------------------------------------------------- 1 | import {Entity, ObjectIdColumn, /*ObjectID,*/ Column} from "../../../../src/index.ts"; 2 | 3 | /** 4 | * @deprecated use item config instead 5 | */ 6 | @Entity() 7 | export class Config { 8 | @ObjectIdColumn() 9 | _id!: any;/*ObjectID;*/ // TODO(uki00a) uncomment this when MongoDriver is implemented. 10 | 11 | @Column({ type: String }) 12 | itemId!: string; 13 | 14 | @Column({ type: "json" }) 15 | data!: any; 16 | } 17 | -------------------------------------------------------------------------------- /test/other-issues/join-empty-relations/entity/Author.ts: -------------------------------------------------------------------------------- 1 | import {Entity} from "../../../../src/decorator/entity/Entity.ts"; 2 | import {PrimaryGeneratedColumn} from "../../../../src/decorator/columns/PrimaryGeneratedColumn.ts"; 3 | import {Column} from "../../../../src/decorator/columns/Column.ts"; 4 | 5 | @Entity() 6 | export class Author { 7 | 8 | @PrimaryGeneratedColumn() 9 | id!: number; 10 | 11 | @Column({ type: String }) 12 | name!: string; 13 | 14 | } 15 | -------------------------------------------------------------------------------- /test/other-issues/limit-with-order-by/entity/Category.ts: -------------------------------------------------------------------------------- 1 | import {Entity} from "../../../../src/decorator/entity/Entity.ts"; 2 | import {PrimaryGeneratedColumn} from "../../../../src/decorator/columns/PrimaryGeneratedColumn.ts"; 3 | import {Column} from "../../../../src/decorator/columns/Column.ts"; 4 | 5 | @Entity() 6 | export class Category { 7 | 8 | @PrimaryGeneratedColumn() 9 | id!: number; 10 | 11 | @Column({ type: String }) 12 | name!: string; 13 | 14 | } 15 | -------------------------------------------------------------------------------- /test/functional/connection/entity/View.ts: -------------------------------------------------------------------------------- 1 | import {Entity} from "../../../../src/decorator/entity/Entity.ts"; 2 | import {PrimaryColumn} from "../../../../src/decorator/columns/PrimaryColumn.ts"; 3 | import {Column} from "../../../../src/decorator/columns/Column.ts"; 4 | 5 | @Entity("view", { synchronize: false }) 6 | export class View { 7 | 8 | @PrimaryColumn({ type: Number }) 9 | id!: number; 10 | 11 | @Column({ type: String }) 12 | title!: string; 13 | 14 | } 15 | -------------------------------------------------------------------------------- /test/functional/query-builder/insert-on-conflict/entity/Post.ts: -------------------------------------------------------------------------------- 1 | import {Entity} from "../../../../../src/decorator/entity/Entity.ts"; 2 | import {Column} from "../../../../../src/decorator/columns/Column.ts"; 3 | import {PrimaryColumn} from "../../../../../src/decorator/columns/PrimaryColumn.ts"; 4 | 5 | @Entity() 6 | export class Post { 7 | 8 | @PrimaryColumn({ type: String }) 9 | id!: string; 10 | 11 | @Column({ type: String }) 12 | title!: string; 13 | 14 | } 15 | -------------------------------------------------------------------------------- /test/functional/query-builder/insert/entity/Post.ts: -------------------------------------------------------------------------------- 1 | import {Entity} from "../../../../../src/decorator/entity/Entity.ts"; 2 | import {PrimaryGeneratedColumn} from "../../../../../src/decorator/columns/PrimaryGeneratedColumn.ts"; 3 | import {Column} from "../../../../../src/decorator/columns/Column.ts"; 4 | 5 | @Entity() 6 | export class Post { 7 | 8 | @PrimaryGeneratedColumn() 9 | id!: number; 10 | 11 | @Column({ type: String }) 12 | title!: string; 13 | 14 | } 15 | -------------------------------------------------------------------------------- /test/functional/query-builder/relation-id/many-to-many/embedded/entity/Post.ts: -------------------------------------------------------------------------------- 1 | import {Entity} from "../../../../../../../src/decorator/entity/Entity.ts"; 2 | import {Column} from "../../../../../../../src/decorator/columns/Column.ts"; 3 | import {Counters} from "./Counters.ts"; 4 | 5 | @Entity() 6 | export class Post { 7 | 8 | @Column({ type: String }) 9 | title!: string; 10 | 11 | @Column(() => Counters, { prefix: "cnt" }) 12 | counters!: Counters; 13 | 14 | } 15 | -------------------------------------------------------------------------------- /test/functional/repository/find-options/entity/User.ts: -------------------------------------------------------------------------------- 1 | import {Entity} from "../../../../../src/decorator/entity/Entity.ts"; 2 | import {PrimaryGeneratedColumn} from "../../../../../src/decorator/columns/PrimaryGeneratedColumn.ts"; 3 | import {Column} from "../../../../../src/decorator/columns/Column.ts"; 4 | 5 | @Entity() 6 | export class User { 7 | 8 | @PrimaryGeneratedColumn() 9 | id!: number; 10 | 11 | @Column({ type: String }) 12 | name!: string; 13 | 14 | } 15 | -------------------------------------------------------------------------------- /test/github-issues/620/entity/Dog.ts: -------------------------------------------------------------------------------- 1 | import {Entity} from "../../../../src/index.ts"; 2 | import {PrimaryColumn} from "../../../../src/decorator/columns/PrimaryColumn.ts"; 3 | import {OneToMany} from "../../../../src/decorator/relations/OneToMany.ts"; 4 | import {Cat} from "./Cat.ts"; 5 | 6 | @Entity() 7 | export class Dog { 8 | 9 | @PrimaryColumn({ type: String }) 10 | DogID!: string; 11 | 12 | @OneToMany(type => Cat, cat => cat.dog) 13 | cats!: Cat[]; 14 | 15 | } 16 | -------------------------------------------------------------------------------- /test/github-issues/778/entity/Category.ts: -------------------------------------------------------------------------------- 1 | import {Entity} from "../../../../src/decorator/entity/Entity.ts"; 2 | import {Column} from "../../../../src/decorator/columns/Column.ts"; 3 | import {PrimaryGeneratedColumn} from "../../../../src/decorator/columns/PrimaryGeneratedColumn.ts"; 4 | 5 | @Entity() 6 | export class Category { 7 | 8 | @PrimaryGeneratedColumn({ type: "bigint" }) 9 | id!: string; 10 | 11 | @Column({ type: String }) 12 | name!: string; 13 | 14 | } 15 | -------------------------------------------------------------------------------- /test/github-issues/778/entity/Question.ts: -------------------------------------------------------------------------------- 1 | import {Entity} from "../../../../src/decorator/entity/Entity.ts"; 2 | import {Column} from "../../../../src/decorator/columns/Column.ts"; 3 | import {PrimaryGeneratedColumn} from "../../../../src/decorator/columns/PrimaryGeneratedColumn.ts"; 4 | 5 | @Entity() 6 | export class Question { 7 | 8 | @PrimaryGeneratedColumn({ type: "smallint" }) 9 | id!: number; 10 | 11 | @Column({ type: String }) 12 | name!: string; 13 | 14 | } 15 | -------------------------------------------------------------------------------- /test/other-issues/escaping-function-parameter/entity/Post.ts: -------------------------------------------------------------------------------- 1 | import {Entity} from "../../../../src/decorator/entity/Entity.ts"; 2 | import {PrimaryGeneratedColumn} from "../../../../src/decorator/columns/PrimaryGeneratedColumn.ts"; 3 | import {Column} from "../../../../src/decorator/columns/Column.ts"; 4 | 5 | @Entity() 6 | export class Post { 7 | 8 | @PrimaryGeneratedColumn() 9 | id!: number; 10 | 11 | @Column({ type: String }) 12 | title!: string; 13 | 14 | } 15 | -------------------------------------------------------------------------------- /test/other-issues/mssql-add-column-with-default-value/entity/Post.ts: -------------------------------------------------------------------------------- 1 | import {Entity} from "../../../../src/decorator/entity/Entity.ts"; 2 | import {PrimaryGeneratedColumn} from "../../../../src/decorator/columns/PrimaryGeneratedColumn.ts"; 3 | import {Column} from "../../../../src/decorator/columns/Column.ts"; 4 | 5 | @Entity() 6 | export class Post { 7 | @PrimaryGeneratedColumn() 8 | id!: number; 9 | 10 | @Column({ type: String }) 11 | title!: string; 12 | 13 | } 14 | -------------------------------------------------------------------------------- /sample/sample10-mixed/entity/ImageDetails.ts: -------------------------------------------------------------------------------- 1 | import {Column, Entity, OneToOne, PrimaryGeneratedColumn} from "../../../src/index"; 2 | import {Image} from "./Image"; 3 | 4 | @Entity("sample10_image_details") 5 | export class ImageDetails { 6 | 7 | @PrimaryGeneratedColumn() 8 | id: number; 9 | 10 | @Column() 11 | meta: string; 12 | 13 | @Column() 14 | comment: string; 15 | 16 | @OneToOne(type => Image, image => image.details) 17 | image: Image; 18 | 19 | } -------------------------------------------------------------------------------- /src/error/DriverOptionNotSetError.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Thrown if some required driver's option is not set. 3 | */ 4 | export class DriverOptionNotSetError extends Error { 5 | name = "DriverOptionNotSetError"; 6 | 7 | constructor(optionName: string) { 8 | super(); 9 | Object.setPrototypeOf(this, DriverOptionNotSetError.prototype); 10 | this.message = `Driver option (${optionName}) is not set. Please set it to perform connection to the database.`; 11 | } 12 | 13 | } -------------------------------------------------------------------------------- /src/error/OptimisticLockCanNotBeUsedError.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Thrown when an optimistic lock cannot be used in query builder. 3 | */ 4 | export class OptimisticLockCanNotBeUsedError extends Error { 5 | name = "OptimisticLockCanNotBeUsedError"; 6 | 7 | constructor() { 8 | super(); 9 | Object.setPrototypeOf(this, OptimisticLockCanNotBeUsedError.prototype); 10 | this.message = `The optimistic lock can be used only with getOne() method.`; 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /test/functional/query-builder/subquery/entity/Category.ts: -------------------------------------------------------------------------------- 1 | import {Entity} from "../../../../../src/decorator/entity/Entity.ts"; 2 | import {PrimaryGeneratedColumn} from "../../../../../src/decorator/columns/PrimaryGeneratedColumn.ts"; 3 | import {Column} from "../../../../../src/decorator/columns/Column.ts"; 4 | 5 | @Entity() 6 | export class Category { 7 | 8 | @PrimaryGeneratedColumn() 9 | id!: number; 10 | 11 | @Column({ type: String }) 12 | name!: string; 13 | 14 | } 15 | -------------------------------------------------------------------------------- /test/github-issues/1545/entity/ValidationModel.ts: -------------------------------------------------------------------------------- 1 | import { Column, OneToMany, Entity } from "../../../../src/index.ts"; 2 | import { DataModel } from "./DataModel.ts"; 3 | 4 | @Entity() 5 | export class ValidationModel { 6 | @Column({ 7 | type: "integer", 8 | primary: true 9 | }) 10 | validation!: number; 11 | 12 | @OneToMany( 13 | type => DataModel, 14 | dataModel => dataModel.validations 15 | ) 16 | dataModel!: DataModel[]; 17 | } 18 | -------------------------------------------------------------------------------- /test/github-issues/1703/entity/UserEntity.ts: -------------------------------------------------------------------------------- 1 | import {Entity, OneToMany, PrimaryGeneratedColumn} from "../../../../src/index.ts"; 2 | import {UserToOrganizationEntity} from "./UserToOrganizationEntity.ts"; 3 | 4 | @Entity("user") 5 | export class UserEntity { 6 | 7 | @PrimaryGeneratedColumn() 8 | id?: number; 9 | 10 | @OneToMany(type => UserToOrganizationEntity, userToOrganization => userToOrganization.user) 11 | organizations!: UserToOrganizationEntity[]; 12 | 13 | } 14 | -------------------------------------------------------------------------------- /test/github-issues/1839/entity/Category.ts: -------------------------------------------------------------------------------- 1 | import {Entity, PrimaryColumn} from "../../../../src/index.ts"; 2 | import {ManyToMany} from "../../../../src/decorator/relations/ManyToMany.ts"; 3 | import {Post} from "./Post.ts"; 4 | 5 | @Entity() 6 | export class Category { 7 | 8 | @PrimaryColumn({ type: String, collation: "ascii_general_ci", charset: "ascii" }) 9 | id!: string; 10 | 11 | @ManyToMany(type => Post, post => post.categories) 12 | posts!: Post[]; 13 | 14 | } 15 | -------------------------------------------------------------------------------- /test/github-issues/2557/transformer.ts: -------------------------------------------------------------------------------- 1 | export class WrappedNumber { 2 | constructor (private wrapped: number) {} 3 | 4 | getWrapped(): number { 5 | return this.wrapped; 6 | } 7 | } 8 | 9 | export const transformer = { 10 | lastValue : undefined as any, 11 | from(val: number) { 12 | return new WrappedNumber(val); 13 | }, 14 | to(w: WrappedNumber) { 15 | transformer.lastValue = w; 16 | return w.getWrapped(); 17 | } 18 | }; 19 | -------------------------------------------------------------------------------- /sample/sample5-subscribers/entity/PostAuthor.ts: -------------------------------------------------------------------------------- 1 | import {Column, Entity, PrimaryGeneratedColumn} from "../../../src/index"; 2 | import {Post} from "./Post"; 3 | import {OneToMany} from "../../../src/decorator/relations/OneToMany"; 4 | 5 | @Entity("sample5_post_author") 6 | export class PostAuthor { 7 | 8 | @PrimaryGeneratedColumn() 9 | id: number; 10 | 11 | @Column() 12 | name: string; 13 | 14 | @OneToMany(type => Post, post => post.author) 15 | posts: Post[]; 16 | 17 | } -------------------------------------------------------------------------------- /sample/sample7-pagination/entity/PostAuthor.ts: -------------------------------------------------------------------------------- 1 | import {Column, Entity, PrimaryGeneratedColumn} from "../../../src/index"; 2 | import {Post} from "./Post"; 3 | import {OneToMany} from "../../../src/decorator/relations/OneToMany"; 4 | 5 | @Entity("sample7_post_author") 6 | export class PostAuthor { 7 | 8 | @PrimaryGeneratedColumn() 9 | id: number; 10 | 11 | @Column() 12 | name: string; 13 | 14 | @OneToMany(type => Post, post => post.author) 15 | posts: Post[]; 16 | 17 | } -------------------------------------------------------------------------------- /src/error/MustBeEntityError.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Thrown when method expects entity but instead something else is given. 3 | */ 4 | export class MustBeEntityError extends Error { 5 | name = "MustBeEntityError"; 6 | 7 | constructor(operation: string, wrongValue: any) { 8 | super(); 9 | Object.setPrototypeOf(this, MustBeEntityError.prototype); 10 | this.message = `Cannot ${operation}, given value must be an entity, instead "${wrongValue}" is given.`; 11 | } 12 | 13 | } -------------------------------------------------------------------------------- /test/functional/connection/modules/blog/entity/Blog.ts: -------------------------------------------------------------------------------- 1 | import {Entity} from "../../../../../../src/decorator/entity/Entity.ts"; 2 | import {PrimaryGeneratedColumn} from "../../../../../../src/decorator/columns/PrimaryGeneratedColumn.ts"; 3 | import {Column} from "../../../../../../src/decorator/columns/Column.ts"; 4 | 5 | @Entity() 6 | export class Blog { 7 | 8 | @PrimaryGeneratedColumn() 9 | id!: number; 10 | 11 | @Column({ type: String }) 12 | name!: string; 13 | 14 | } 15 | -------------------------------------------------------------------------------- /test/functional/connection/modules/video/entity/Video.ts: -------------------------------------------------------------------------------- 1 | import {Entity} from "../../../../../../src/decorator/entity/Entity.ts"; 2 | import {PrimaryGeneratedColumn} from "../../../../../../src/decorator/columns/PrimaryGeneratedColumn.ts"; 3 | import {Column} from "../../../../../../src/decorator/columns/Column.ts"; 4 | 5 | @Entity() 6 | export class Video { 7 | 8 | @PrimaryGeneratedColumn() 9 | id!: number; 10 | 11 | @Column({ type: String }) 12 | name!: string; 13 | 14 | } 15 | -------------------------------------------------------------------------------- /test/functional/entity-schema/basic/entity/CategoryEntity.ts: -------------------------------------------------------------------------------- 1 | import {EntitySchema} from "../../../../../src/index.ts"; 2 | import {Category} from "../model/Category.ts"; 3 | 4 | export const CategoryEntity = new EntitySchema({ 5 | name: "category", 6 | columns: { 7 | id: { 8 | type: Number, 9 | primary: true, 10 | generated: true 11 | }, 12 | name: { 13 | type: String 14 | } 15 | } 16 | }); 17 | -------------------------------------------------------------------------------- /test/functional/migrations/show-command/migration/1530542855524-ExampleMigration.ts: -------------------------------------------------------------------------------- 1 | import { MigrationInterface } from "../../../../../src/migration/MigrationInterface.ts"; 2 | import { QueryRunner } from "../../../../../src/query-runner/QueryRunner.ts"; 3 | 4 | export class ExampleMigration1530542855524 implements MigrationInterface { 5 | public async up(queryRunner: QueryRunner): Promise { 6 | } 7 | public async down(queryRunner: QueryRunner): Promise { 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /test/functional/query-builder/enabling-transaction/entity/Post.ts: -------------------------------------------------------------------------------- 1 | import {Entity} from "../../../../../src/decorator/entity/Entity.ts"; 2 | import {PrimaryGeneratedColumn} from "../../../../../src/decorator/columns/PrimaryGeneratedColumn.ts"; 3 | import {Column} from "../../../../../src/decorator/columns/Column.ts"; 4 | 5 | @Entity() 6 | export class Post { 7 | 8 | @PrimaryGeneratedColumn() 9 | id!: number; 10 | 11 | @Column({ type: String }) 12 | title!: string; 13 | 14 | } 15 | -------------------------------------------------------------------------------- /test/functional/repository/basic-methods/entity/Category.ts: -------------------------------------------------------------------------------- 1 | import {Entity} from "../../../../../src/decorator/entity/Entity.ts"; 2 | import {PrimaryGeneratedColumn} from "../../../../../src/decorator/columns/PrimaryGeneratedColumn.ts"; 3 | import {Column} from "../../../../../src/decorator/columns/Column.ts"; 4 | 5 | @Entity() 6 | export class Category { 7 | 8 | @PrimaryGeneratedColumn() 9 | id!: number; 10 | 11 | @Column({ type: String }) 12 | name!: string; 13 | 14 | } 15 | -------------------------------------------------------------------------------- /test/functional/repository/delete-by-id-and-ids/entity/Post.ts: -------------------------------------------------------------------------------- 1 | import {Entity} from "../../../../../src/decorator/entity/Entity.ts"; 2 | import {PrimaryGeneratedColumn} from "../../../../../src/decorator/columns/PrimaryGeneratedColumn.ts"; 3 | import {Column} from "../../../../../src/decorator/columns/Column.ts"; 4 | 5 | @Entity() 6 | export class Post { 7 | 8 | @PrimaryGeneratedColumn() 9 | id!: number; 10 | 11 | @Column({ type: String }) 12 | title!: string; 13 | 14 | } 15 | -------------------------------------------------------------------------------- /test/functional/repository/find-options-relations/entity/User.ts: -------------------------------------------------------------------------------- 1 | import {Entity} from "../../../../../src/decorator/entity/Entity.ts"; 2 | import {PrimaryGeneratedColumn} from "../../../../../src/decorator/columns/PrimaryGeneratedColumn.ts"; 3 | import {Column} from "../../../../../src/decorator/columns/Column.ts"; 4 | 5 | @Entity() 6 | export class User { 7 | 8 | @PrimaryGeneratedColumn() 9 | id!: number; 10 | 11 | @Column({ type: String }) 12 | name!: string; 13 | 14 | } 15 | -------------------------------------------------------------------------------- /test/functional/repository/find-options/entity/Category.ts: -------------------------------------------------------------------------------- 1 | import {Entity} from "../../../../../src/decorator/entity/Entity.ts"; 2 | import {PrimaryGeneratedColumn} from "../../../../../src/decorator/columns/PrimaryGeneratedColumn.ts"; 3 | import {Column} from "../../../../../src/decorator/columns/Column.ts"; 4 | 5 | @Entity() 6 | export class Category { 7 | 8 | @PrimaryGeneratedColumn() 9 | id!: number; 10 | 11 | @Column({ type: String }) 12 | name!: string; 13 | 14 | } 15 | -------------------------------------------------------------------------------- /test/functional/transaction/transaction-decorator/entity/Post.ts: -------------------------------------------------------------------------------- 1 | import {Entity} from "../../../../../src/decorator/entity/Entity.ts"; 2 | import {PrimaryGeneratedColumn} from "../../../../../src/decorator/columns/PrimaryGeneratedColumn.ts"; 3 | import {Column} from "../../../../../src/decorator/columns/Column.ts"; 4 | 5 | @Entity() 6 | export class Post { 7 | 8 | @PrimaryGeneratedColumn() 9 | id!: number; 10 | 11 | @Column({ type: String }) 12 | title!: string; 13 | 14 | } 15 | --------------------------------------------------------------------------------