34 Commits

Author SHA1 Message Date
StefanZivkovic
c418aae39a
docs: update cli related docs (#9659)
- remove cli.entitiesDir description
- remove cli.subscribersDir description
- remove cli from Data Source Options example
- extend migration:run examples with -- -d path-to-datasource-config
- extend migration:revert examples with -- -d path-to-datasource-config
- extend migration:show examples with -- -d path-to-datasource-config
- extend migration:create examples with path-to-migrations-dir/migrationName

Co-authored-by: Stefan <stefi@sprintingsoftware.com>
2023-02-07 12:34:37 +05:00
kz-d
6e9151323a
docs: update "migrate:show error code" description (#9476) 2022-12-03 19:41:23 +05:00
Alessandro Maruccia
8e9b273885
docs: update generate migration docs (#8896) 2022-04-15 20:25:45 +05:00
Gilad S
05fc744469
feat: add typeorm CLI variations that include ts-node (#8776)
* feat: add typeorm CLI variations that include `ts-node`

Add `typeorm-ts-node-commonjs` and `typeorm-ts-node-esm` CLI commands.
This removes the need to manually write `node --require ts-node/register ./node_modules/typeorm/cli.js` or `node --loader ts-node/esm ./node_modules/typeorm/cli.js` in order to use TypeORM CLI without transpiling the code in advance.

* style: formatting
2022-03-22 22:21:14 +05:00
Umed Khudoiberdiev
3b8a031ece
0.3.0 (#8616)
* added find options and new option relationLoadStrategy

* find now returns null instead of undefined; removed primary relations support; bugfixing; added some changes and tests from next branch;

* added typename to connection options; added data loader types, lot of deprecations; new es2020 emit by tsc; new custom repositories syntax

* applied lint fixing

* replaced some instanceof checks

* reverting docker compose image versions

* optimizing imports

* reverting back some instanceof checks to prevent compiler errors

* downgrading es compilation version

* docs: remove "primary" from relation options (#8619)

remove ex-line 26 for being deprecated in 0.3.0:
"* `primary: boolean` - Indicates whether this relation's column will be a primary column or not."

* Revert "reverting back some instanceof checks to prevent compiler errors"

This reverts commit 7bf12a39e2297d097aa2a42989afd0e9e4f49bb0.

* Revert "optimizing imports"

This reverts commit 7588ac14e4f1bf1a82e3b7883134b9c2c8ae5f3f.

* Revert "replaced some instanceof checks"

This reverts commit bfa5a2d706f697ed1c1beb38b4455c0d33121e5a.

* fixing few comments

* removing transaction decorators

* this test is invalid - it's not clear why the hell getTreeRepository will throw an error and it's not clear what kind of error its going to throw

* addded mixed list support in connection options

* trying to fix oracle length issue

* lintfix

* removed shorten usages

* added named entity target support to the connection

* fixing entity target support in relation options via entity schema

* debugging oracle issue

* fixed issue with alias not being shortened in many to many alias cases

* some day we'll have a prettier.

* fixing oracle tests

* fixing oracle failing test

* removed "null" support in where expressions; fixed softDelete and restore incorrect usages

* renamed FindConditions to FindOptionsWhere

* version bump

* docs: update loading relation in find method (v 0.3.0) (#8621)

* docs: update relation definition method

Update the method that allows loading a specific relation inside the find method.
This method is found on the one-to-one-relations page.
Change `const users = await userRepository.find({ relations: ["profile"] });` to `const users = await userRepository.find({ relations: {profile: true});`.

* fix formatting

Co-authored-by: Umed Khudoiberdiev <pleerock.me@gmail.com>

* docs: change relations option definition (#8620)

* docs: change relations option definition

change line 139 from 
`const users = await connection.getRepository(User).find({ relations: ["profile", "photos", "videos"] });`
to
`const users = await connection.getRepository(User).find({ relations: { profile: true, photos: true, videos: true] });`
to reflect version 0.3.0 changes

* docs: change relations option definition

Rectified a type on line 139
from:
`const users = await connection.getRepository(User).find({ relations: { profile: true, photos: true, videos: true] });`
to
`const users = await connection.getRepository(User).find({ relations: { profile: true, photos: true, videos: true} });`

* formatting

Co-authored-by: Umed Khudoiberdiev <pleerock.me@gmail.com>

* lint

* improved find options types

* fixed types and removed nonnever because it causes circual issue for some reason

* docs: update entitymanager definition (#8623)

* docs: update entitymanager definition

change the "What is EntityManager?" page to be up-to-date with v 0.3.0

1. line 6 changes from
`You can access the entity manager via 'getManager()' or from 'Connection'.`
to 
`You can access the entity manager via DataSource's manager.`

2. the import on `getManager` in line 10 becomes `Manager` that the user have configured beforehand:
`import {getManager} from "typeorm";`
becomes 
`import {Manager} from "./config/DataSource";`

3.change entityManager definition in line 13:
from
`const entityManager = getManager(); // you can also get it via getConnection().manager`
to
`const entityManager = Manager;`

* docs: update entitymanager definition

changed line 10 from: 
`import {Manager} from "./config/DataSource";`
to
`import {DataSource} from "typeorm";`

and changed line 13 and 14 from: 
`const entityManager = Manager;`
`const user = await entityManager.findOne(User, 1);`
to 
`const myDataSource = new DataSource({ /*...*/ });`
`const user = await myDataSource.manager.findOne(User, 1);`

for a simpler way of describing the origin of DataSource and how it works.

* In return type doesn't seem to work in all cases

* feat: mssql v7 support (#8592)

Adds support for v7 of the mssql library as v6 is EOL. This also makes use of the new toReadableStream method on requests to return a native stream where required.

* fix: prefix relation id columns contained in embedded entities (#6977) (#7432)

* fix: prefix relation id columns contained in embedded entities (#6977)

Searches embedded entity columns for relation ID column if relation column
is in embedded entity. If not found, creates new relation ID with embedded
metadata set to match the relation column.

fixes: #2254
fixes: #3132
fixes: #3226
fixes: #6977

* test: prefix subcounters sub-entity with "sub" to fit in 30 character identifier for oracle

Problem introduced with #6981

* fix: find by Date object in sqlite driver (#7538)

* fix: find by Date object in sqlite driver

In sqlite, Date objects are persisted as UtcDatetimeString.
But a Date object parameter was escaped with .toISOString(), making such queries impossible.
This commit aligns both transforms.
This bug does *not* apply to better-sql where you can only bind numbers, strings, bigints, buffers,
and null.
This is breaking for when the user inserted their dates manually as ISO and relied on this old
maltransformation, after this their find()s by Date won't work anymore.

BREAKING CHANGE: Change Date serialization in selects
Closes: #2286

* add failing test

* fix: find by Date object in sqlite driver (with query builder)

Also consider query builder parameter escaping

* test: add test for 3426

Co-authored-by: James Ward <james@notjam.es>

* manually ported changes from #7796

* updated changelog

* fixes after merge

* new findOne syntax

* new find* syntax

* new find* syntax

* lint

* tsc version bump

* tsc version bump and fixed mongodb issues

* moved date fns into non dev deps

* returned oracledb dep into place

* removed lock files

* returned lock files back

* eslint upgrade

* fixing mongodb issue

* fixing mongodb issue

* test: keep junction aliases short (#8637)

Tests a fix for an issue where junction aliases (e.g. in many-to-many relations)
are not unique because they are too long and thus truncated by the driver.

Closes: #8627
Related to: 76cee41dcf1c146d02715c7f48fed33672d28c67

* fixing mongodb issues

* fixing sqlite test

* fixing sqlite test

* fixing sqlite test

* fixing mongodb test

* fixing entity schema tests

* fixing entity schema tests

* merged latest master

* removed driver instanceof checks

* removed function instanceof checks

* removed Object instanceof checks

* removing instanceof checks...

* fixing instanceof checks

* added InstanceChecker to remove remaining instanceof checks

* fixed failing test

* linting

* fixing failing test

* version bump

* compiler fixes

* Connection type usages replace to DataSource

* updated dev deps

* updated deps, add prettier, removed oracledb due to m1 issue

* chalk downgrade

* fixing failing test

* applied prettier formatting

* replaced eslint to prettier

* okay I think we can call it lint

* fixing linting

* fixed prettier introduced compiler bug

* fixed failing test

* prettier;

* fixed failing test

* alias shortening only for junction tables;
fixed failing tests;

* changed aurora db names and reverted change of junction table name shorten algorithm

* format

* removed platform from docker compose

* made numeric parameters to not use parameters to prevent parameters number limit issue. Also enabled shorten only for junction tables

* fixing test

* fixing returning columns bugs

* fixing test

* fixed returning issue

* fixing merge conflicts

* updating documentation

* working on docs / improving api

* working on docs

* fixed isConnected issue

* re-worked commands

* commenting cli command tests for now

* commenting cli command tests for now

* removed platform

* returned Connection back

* refactor: export tree repository helper methods (#8753)

* Migrated protected tree methods to util class

* Added tree repository extend override

* Ran prettier format

* merge master into 0.3.0

Co-authored-by: Bitcollage <serkan.sipahi@yahoo.de>

* working on documentation

Co-authored-by: Bilel Taktak <47742269+Parsath@users.noreply.github.com>
Co-authored-by: Salah Azzouz <52634440+Salah-Azzouz@users.noreply.github.com>
Co-authored-by: Daniel Hensby <dhensby@users.noreply.github.com>
Co-authored-by: Nebojša Cvetković <nebkat@gmail.com>
Co-authored-by: Philip Waritschlager <philip+github@waritschlager.de>
Co-authored-by: James Ward <james@notjam.es>
Co-authored-by: Felix Gohla <37421906+felix-gohla@users.noreply.github.com>
Co-authored-by: Dmitry Zotov <dmzt08@gmail.com>
Co-authored-by: Jimmy Chen <50786287+Q16solver@users.noreply.github.com>
Co-authored-by: Bitcollage <serkan.sipahi@yahoo.de>
2022-03-17 21:01:45 +05:00
Gilad S
3a694dd3e9
feat: ESM support (#8536)
* feat: support importing TypeORM in esm projects

Closes: #6974
Closes: #6941

* bugfix: generate index.mjs directly out of commonjs exports

The new implementation generates ESM exports directly out of the commonjs exports, and provides a default export to maintain compatability with existing `import`s of the commonjs implementation

* feat: support loading ESM entity and connection config files

When TypeORM tries to load an entity file or a connection config file, it will determine what is the appropriate module system to use for the file and then `import` or `require` it as it sees fit.

Closes: #7516
Closes: #7159

* fix: adapt ImportUtils.importOrRequireFile tests to older version of nodejs

* fix: improved importOrRequireFile implementation

* feat: add solution to circular dependency issue in ESM projects

* docs: added FAQ regarding ESM projects

* chore: add `"type": "commonjs"` to package.json

* style

* docs: improve `ts-node` usage examples for CLI commands in ESM projects

* feat: add support for generating an ESM base project

* refactor: renamed `Related` type to `Relation`

* docs: added a section in the Getting Started guide regarding the `Relation` wrapper type in ESM projects

* docs: improved documentation of the `Relation` type

* docs: improved documentation of the `Relation` type

* docs: added ESM support to the list of TypeORM features
2022-01-31 14:25:58 +05:00
Audwin
90a8deb638
docs: Improve various formatting code syntax and capitalisation (#8449)
* docs: Improve various docs formatting

code syntax highlight on `leftJoinAndSelect`
capitalise SQL word

* docs: capitalise SQL word on classes methods docs

* docs: lowercase SQL word to trigger auto-test

* docs: uppercase SQL word to trigger auto-test
2021-12-11 12:58:57 +05:00
rccursach
70db8451c0
docs: fix small typo on package.json script example (#7408)
Add missing colon in JSON property at `package.json` `"script"` example
2021-02-24 14:05:48 +05:00
Christian Holm
8244ea1371
feat: Exit with code 1 on empty migration:generate (#6978)
This makes the `migration:generate` cli command exit with code 1 if no changes were found between the database and the schema from the code.
2020-10-30 10:23:00 +05:00
Fernando Moreira
c9f184e887
docs: update using-cli.md (#6407) 2020-07-16 14:54:30 +03:00
Jérôme Steunou
826ed36b46
docs: fix typeorm alias for TS (#6045)
Just did not work with actual version of ts-node and others modules
2020-05-15 07:46:51 +03:00
Justin Vallelonga
f9505c9b23
docs: very small typo fix (#5551)
adds 's' to scripts section reference
2020-02-20 15:07:39 +05:00
JB Reefer
00d46e1ef0 docs: Update using-cli.md (#4618)
Fix typo
2019-08-24 14:08:26 +05:00
Umed Khudoiberdiev
8592ffae8b
Merge pull request #4155 from ambroiseRabier/improvingCLIDoc
Improving cli doc
2019-05-30 11:49:40 +05:00
James Judd
7ec82c79b1 remove emojis 👋 2019-05-27 19:42:22 +10:00
James Judd
ab5857adab explain the output 2019-05-23 10:11:29 +10:00
James Judd
e8f53b1439 add cli docs 2019-05-23 10:09:35 +10:00
Ambroise Rabier
a82c58ef56 Replacing discrete 'how to install CLI' in migrations.md with a visible link to 'install CLI' documentation as pre-requisite. 2019-05-18 16:46:12 +02:00
Ambroise Rabier
5223b95374 Improving using-cli installation instructions and how to read the doc. 2019-05-18 16:32:42 +02:00
Jeff Chan
236db6a9e5
Update cli doc to work on both windows and mac 2019-01-16 21:53:57 +08:00
Jeff Chan
266b8c2899
Update doc to explain how to use the CLI with typescript setup 2018-12-21 16:59:37 +08:00
LeeJunHyeok
5ea9a85f14 modify typing errors 2018-06-06 22:25:07 +09:00
ChangJoo Park(박창주)
690a4868d4
Fix typo. migration command. migrations: to migration 2018-04-19 23:21:04 +09:00
Umed Khudoiberdiev
6089131013 Merge branch 'master' into next
* master: (25 commits)
  version bump
  skipped failing test for now
  version bump
  fixed issue with entity order by applied to update query builder
  Update README.md
  Add TYPEORM_DATABASE to available env options
  Provide failing test
  chore: fix typo in repository clear test filename
  minor lint fix
  delete entities using tablePath
  implement timezone based tests for multiple database drivers
  remove UTC transformation from drivers on write and read
  fixed broken lazy relation behaviour with broadcaster
  Fixes to Postgres, MySQL and MSSQL drivers propagating unhandled errors and crashing the hosting application
  remove array cast apply on function typed columns
  exit process on migrations:run command complete
  removed only test
  fixes #1720
  added test for #1703
  Update cli docs for create migration
  ...

# Conflicts:
#	CHANGELOG.md
#	README.md
#	package-lock.json
#	package.json
#	src/driver/mysql/MysqlDriver.ts
#	src/driver/postgres/PostgresDriver.ts
#	src/driver/sqlite-abstract/AbstractSqliteDriver.ts
#	src/persistence/SubjectOperationExecutor.ts
#	src/subscriber/Broadcaster.ts
#	test/github-issues/1716/issue-1716.ts
2018-03-26 18:15:13 +05:00
Daniel Lang
8a83ca057f cli: renamed migrations:run to migration:run 2018-03-12 11:30:02 +01:00
Jeremy Forsythe
8bcd907f7d
Update cli docs for create migration
CLI command is `migrations:create` (plural) not `migration:create` (singular)
2018-03-05 14:05:22 -05:00
Daniel Lang
a62384a762 cli: renamed migrations:create, migrations:generate and migrations:revert to migration:create, migration:generate and migration:revert 2018-03-02 19:49:17 +01:00
Matt Neal
170a23ef3e
Update using-cli.md
Grammatical and punctuation changes to improve readability and bring formatting in line with other documentation.
2018-01-29 17:36:49 -05:00
Daniel Lang
bd9041f0f5 spelling and general improvements (part 5) 2017-10-04 13:08:40 +02:00
Umed Khudoiberdiev
2758aec2a1 multiple fixes in CLI commands, fixed #943, #911 2017-09-27 11:43:49 +05:00
Umed Khudoiberdiev
1f3ac88d5f improved docs 2017-09-26 21:15:46 +05:00
Umed Khudoiberdiev
fb87751156 added init and version commands 2017-09-13 21:40:34 +05:00
Umed Khudoiberdiev
f9a7ce07d4 added using cli docs 2017-08-30 17:23:16 +05:00
Umed Khudoiberdiev
e297c5d516 added docs for future edit 2017-07-07 18:10:43 +05:00