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
This commit is contained in:
Audwin 2021-12-11 18:58:57 +11:00 committed by GitHub
parent 0626ed1f0b
commit 90a8deb638
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
25 changed files with 111 additions and 113 deletions

View File

@ -196,9 +196,9 @@ This new feature change bahviour of typeorm to allow use new magic decorator...
Closes: #22222
```
Doc update:
Docs update:
```
doc: update supported mssql column types
docs: update supported mssql column types
```
Breaking change:
```

View File

@ -8,9 +8,9 @@
In TypeORM you can use both the Active Record and the Data Mapper patterns.
Using the Active Record approach, you define all your query methods inside the model itself, and you save, remove, and load objects using model methods.
Using the Active Record approach, you define all your query methods inside the model itself, and you save, remove, and load objects using model methods.
Simply said, the Active Record pattern is an approach to access your database within your models.
Simply said, the Active Record pattern is an approach to access your database within your models.
You can read more about the Active Record pattern on [Wikipedia](https://en.wikipedia.org/wiki/Active_record_pattern).
Example:
@ -20,16 +20,16 @@ import {BaseEntity, Entity, PrimaryGeneratedColumn, Column} from "typeorm";
@Entity()
export class User extends BaseEntity {
@PrimaryGeneratedColumn()
id: number;
@Column()
firstName: string;
@Column()
lastName: string;
@Column()
isActive: boolean;
@ -40,7 +40,6 @@ All active-record entities must extend the `BaseEntity` class, which provides me
Example of how to work with such entity:
```typescript
// example how to save AR entity
const user = new User();
user.firstName = "Timber";
@ -60,7 +59,7 @@ const timber = await User.findOne({ firstName: "Timber", lastName: "Saw" });
`BaseEntity` has most of the methods of the standard `Repository`.
Most of the time you don't need to use `Repository` or `EntityManager` with active record entities.
Now let's say we want to create a function that returns users by first and last name.
Now let's say we want to create a function that returns users by first and last name.
We can create such functions as a static method in a `User` class:
```typescript
@ -68,19 +67,19 @@ import {BaseEntity, Entity, PrimaryGeneratedColumn, Column} from "typeorm";
@Entity()
export class User extends BaseEntity {
@PrimaryGeneratedColumn()
id: number;
@Column()
firstName: string;
@Column()
lastName: string;
@Column()
isActive: boolean;
static findByName(firstName: string, lastName: string) {
return this.createQueryBuilder("user")
.where("user.firstName = :firstName", { firstName })
@ -101,11 +100,11 @@ const timber = await User.findByName("Timber", "Saw");
In TypeORM you can use both the Active Record and Data Mapper patterns.
Using the Data Mapper approach, you define all your query methods in separate classes called "repositories",
and you save, remove, and load objects using repositories.
In data mapper your entities are very dumb - they just define their properties and may have some "dummy" methods.
Using the Data Mapper approach, you define all your query methods in separate classes called "repositories",
and you save, remove, and load objects using repositories.
In data mapper your entities are very dumb - they just define their properties and may have some "dummy" methods.
Simply said, data mapper is an approach to access your database within repositories instead of models.
Simply said, data mapper is an approach to access your database within repositories instead of models.
You can read more about data mapper on [Wikipedia](https://en.wikipedia.org/wiki/Data_mapper_pattern).
Example:
@ -115,16 +114,16 @@ import {Entity, PrimaryGeneratedColumn, Column} from "typeorm";
@Entity()
export class User {
@PrimaryGeneratedColumn()
id: number;
@Column()
firstName: string;
@Column()
lastName: string;
@Column()
isActive: boolean;
@ -151,7 +150,7 @@ const newUsers = await userRepository.find({ isActive: true });
const timber = await userRepository.findOne({ firstName: "Timber", lastName: "Saw" });
```
Now let's say we want to create a function that returns users by first and last name.
Now let's say we want to create a function that returns users by first and last name.
We can create such a function in a "custom repository".
```typescript
@ -160,7 +159,7 @@ import {User} from "../entity/User";
@EntityRepository()
export class UserRepository extends Repository<User> {
findByName(firstName: string, lastName: string) {
return this.createQueryBuilder("user")
.where("user.firstName = :firstName", { firstName })
@ -187,5 +186,5 @@ Both strategies have their own cons and pros.
One thing we should always keep in mind with software development is how we are going to maintain our applications.
The `Data Mapper` approach helps with maintainability, which is more effective in bigger apps.
The `Active record` approach helps keep things simple which works well in smaller apps.
The `Active Record` approach helps keep things simple which works well in smaller apps.
And simplicity is always a key to better maintainability.

View File

@ -2,7 +2,7 @@
You can cache results selected by these `QueryBuilder` methods: `getMany`, `getOne`, `getRawMany`, `getRawOne` and `getCount`.
You can also cache results selected by these `Repository` methods: `find`, `findAndCount`, `findByIds`, and `count`.
You can also cache results selected by these `Repository` methods: `find`, `findAndCount`, `findByIds`, and `count`.
To enable caching you need to explicitly enable it in your connection options:
@ -233,7 +233,7 @@ class CustomQueryResultCache implements QueryResultCache {
}
```
If you wish to ignore cache errors and want the queries to pass through to database in case of cache errors, you can use ignoreErrors option.
If you wish to ignore cache errors and want the queries to pass through to database in case of cache errors, you can use ignoreErrors option.
Example:
```typescript

View File

@ -19,7 +19,7 @@ will execute following query:
SELECT "firstName", "lastName" FROM "user"
```
- `relations` - relations needs to be loaded with the main entity. Sub-relations can also be loaded (shorthand for join and leftJoinAndSelect)
- `relations` - relations needs to be loaded with the main entity. Sub-relations can also be loaded (shorthand for `join` and `leftJoinAndSelect`)
```typescript
userRepository.find({ relations: ["profile", "photos", "videos"] });

View File

@ -5,7 +5,7 @@
* [Deleting many-to-many relations](#deleting-many-to-many-relations)
* [Loading many-to-many relations](#loading-many-to-many-relations)
* [Bi-directional relations](#bi-directional-relations)
* [many-to-many relations with custom properties](#many-to-many-relations-with-custom-properties)
* [Many-to-many relations with custom properties](#many-to-many-relations-with-custom-properties)
## What are many-to-many relations
@ -201,7 +201,6 @@ import { Category } from "./Category";
@Entity()
export class Question {
@PrimaryGeneratedColumn()
id: number;
@ -214,7 +213,6 @@ export class Question {
@ManyToMany(() => Category, category => category.questions)
@JoinTable()
categories: Category[];
}
```
@ -231,7 +229,7 @@ const categoriesWithQuestions = await connection
.getMany();
```
## many-to-many relations with custom properties
## Many-to-many relations with custom properties
In case you need to have additional properties in your many-to-many relationship, you have to create a new entity yourself.
For example, if you would like entities `Post` and `Category` to have a many-to-many relationship with an additional `order` column, then you need to create an entity `PostToCategory` with two `ManyToOne` relations pointing in both directions and with custom columns in it:

View File

@ -10,16 +10,16 @@ import {User} from "./User";
@Entity()
export class Photo {
@PrimaryGeneratedColumn()
id: number;
@Column()
url: string;
@ManyToOne(() => User, user => user.photos)
user: User;
}
```
@ -29,16 +29,16 @@ import {Photo} from "./Photo";
@Entity()
export class User {
@PrimaryGeneratedColumn()
id: number;
@Column()
name: string;
@OneToMany(() => Photo, photo => photo.user)
photos: Photo[];
}
```
@ -105,7 +105,7 @@ await connection.manager.save(photo2);
With [cascades](./relations.md#cascades) enabled you can save this relation with only one `save` call.
To load a user with photos inside you must specify the relation in `FindOptions`:
```typescript
const userRepository = connection.getRepository(User);
const users = await userRepository.find({ relations: ["photos"] });
@ -134,4 +134,5 @@ const photos = await connection
.getMany();
```
With eager loading enabled on a relation, you don't have to specify relations in the find command as it will ALWAYS be loaded automatically. If you use QueryBuilder eager relations are disabled, you have to use leftJoinAndSelect to load the relation.
With eager loading enabled on a relation, you don't have to specify relations in the find command as it will ALWAYS be loaded automatically.
If you use QueryBuilder eager relations are disabled, you have to use `leftJoinAndSelect` to load the relation.

View File

@ -42,13 +42,13 @@ You have thousands of posts in your database.
Now you need to make a new release and rename `title` to `name`.
What would you do?
You need to create a new migration with the following sql query (postgres dialect):
You need to create a new migration with the following SQL query (postgres dialect):
```sql
ALTER TABLE "post" ALTER COLUMN "title" RENAME TO "name";
```
Once you run this sql query your database schema is ready to work with your new codebase.
Once you run this SQL query your database schema is ready to work with your new codebase.
TypeORM provides a place where you can write such sql queries and run them when needed.
This place is called "migrations".
@ -217,7 +217,7 @@ module.exports = class PostRefactoringTIMESTAMP {
```
See, you don't need to write the queries on your own.
The rule of thumb for generating migrations is that you generate them after **each** change you made to your models. To apply multi-line formatting to your generated migration queries, use the `p` (alias for `--pretty`) flag.
The rule of thumb for generating migrations is that you generate them after **each** change you made to your models. To apply multi-line formatting to your generated migration queries, use the `p` (alias for `--pretty`) flag.
## Connection option
If you need to run/revert your migrations for another connection rather than the default, use the `-c` (alias for `--connection`) and pass the config name as an argument
@ -544,7 +544,7 @@ dropColumns(table: Table|string, columns: TableColumn[]|string[]): Promise<void>
```
- `table` - Table object or name
- `columns` - array of TableColumn objects or column names to be dropped
- `columns` - array of TableColumn objects or column names to be dropped
Drops a columns in the table.

View File

@ -36,7 +36,7 @@ const connections = await createConnections([{
}]);
```
This approach allows you to connect to any number of databases you have
This approach allows you to connect to any number of databases you have
and each database will have its own configuration, own entities and overall ORM scope and settings.
For each connection a new `Connection` instance will be created.
@ -71,11 +71,11 @@ const db2Connection = getConnection("db2Connection");
Benefit of using this approach is that you can configure multiple connections with different login credentials,
host, port and even database type itself.
Downside for might be that you'll need to manage and work with multiple connection instances.
Downside for might be that you'll need to manage and work with multiple connection instances.
## Using multiple databases in a single connection
If you don't want to create multiple connections,
If you don't want to create multiple connections,
but want to use multiple databases in a single connection,
you can specify database name per-entity you use:
@ -127,10 +127,10 @@ const users = await connection
.getMany(); // userId is not a foreign key since its cross-database request
```
This code will produce following sql query (depend on database type):
This code will produce following SQL query (depend on database type):
```sql
SELECT * FROM "secondDB"."user" "user", "thirdDB"."photo" "photo"
SELECT * FROM "secondDB"."user" "user", "thirdDB"."photo" "photo"
WHERE "photo"."userId" = "user"."id"
```
@ -200,10 +200,10 @@ const users = await connection
.getMany(); // userId is not a foreign key since its cross-database request
```
This code will produce following sql query (depend on database type):
This code will produce following SQL query (depend on database type):
```sql
SELECT * FROM "secondSchema"."question" "question", "thirdSchema"."photo" "photo"
SELECT * FROM "secondSchema"."question" "question", "thirdSchema"."photo" "photo"
WHERE "photo"."userId" = "user"."id"
```
@ -289,7 +289,7 @@ try {
} finally {
await masterQueryRunner.release();
}
```
If you want to use `slave` in raw queries, you also need to explicitly specify the query runner.
@ -333,7 +333,7 @@ Mysql supports deep configuration:
password: "test",
database: "test"
}],
/**
* If true, PoolCluster will attempt to reconnect when connection fails. (Default: true)
*/

View File

@ -9,16 +9,16 @@ import {Entity, PrimaryGeneratedColumn, Column} from "typeorm";
@Entity()
export class Profile {
@PrimaryGeneratedColumn()
id: number;
@Column()
gender: string;
@Column()
photo: string;
}
```
@ -28,17 +28,17 @@ import {Profile} from "./Profile";
@Entity()
export class User {
@PrimaryGeneratedColumn()
id: number;
@Column()
name: string;
@OneToOne(() => Profile)
@JoinColumn()
profile: Profile;
}
```
@ -85,7 +85,7 @@ await connection.manager.save(user);
With [cascades](./relations.md#cascades) enabled you can save this relation with only one `save` call.
To load user with profile inside you must specify relation in `FindOptions`:
```typescript
const userRepository = connection.getRepository(User);
const users = await userRepository.find({ relations: ["profile"] });
@ -101,9 +101,9 @@ const users = await connection
.getMany();
```
With eager loading enabled on a relation, you don't have to specify relations in the find command as it will ALWAYS be loaded automatically. If you use QueryBuilder eager relations are disabled, you have to use leftJoinAndSelect to load the relation.
With eager loading enabled on a relation, you don't have to specify relations in the find command as it will ALWAYS be loaded automatically. If you use QueryBuilder eager relations are disabled, you have to use `leftJoinAndSelect` to load the relation.
Relations can be uni-directional and bi-directional.
Relations can be uni-directional and bi-directional.
Uni-directional are relations with a relation decorator only on one side.
Bi-directional are relations with decorators on both sides of a relation.
@ -115,19 +115,19 @@ import {User} from "./User";
@Entity()
export class Profile {
@PrimaryGeneratedColumn()
id: number;
@Column()
gender: string;
@Column()
photo: string;
@OneToOne(() => User, user => user.profile) // specify inverse side as a second parameter
user: User;
}
```
@ -137,24 +137,24 @@ import {Profile} from "./Profile";
@Entity()
export class User {
@PrimaryGeneratedColumn()
id: number;
@Column()
name: string;
@OneToOne(() => Profile, profile => profile.user) // specify inverse side as a second parameter
@JoinColumn()
profile: Profile;
}
```
We just made our relation bi-directional. Note, inverse relation does not have a `@JoinColumn`.
`@JoinColumn` must only be on one side of the relation - on the table that will own the foreign key.
Bi-directional relations allow you to join relations from both sides using `QueryBuilder`:
Bi-directional relations allow you to join relations from both sides using `QueryBuilder`:
```typescript
const profiles = await connection

View File

@ -264,7 +264,7 @@ createQueryBuilder()
.from(User, "user")
```
Which will result in the following sql query:
Which will result in the following SQL query:
```sql
SELECT ... FROM users user
@ -659,7 +659,7 @@ const user = await createQueryBuilder("user")
.getOne();
```
This will generate following sql query:
This will generate following SQL query:
```sql
SELECT user.*, photo.* FROM users user
@ -676,7 +676,7 @@ const user = await createQueryBuilder("user")
.getOne();
```
This will generate the following sql query:
This will generate the following SQL query:
```sql
SELECT user.*, photo.* FROM users user

View File

@ -12,7 +12,7 @@
* [Sync database schema](#sync-database-schema)
* [Log sync database schema queries without actual running them](#log-sync-database-schema-queries-without-actual-running-them)
* [Drop database schema](#drop-database-schema)
* [Run any sql query](#run-any-sql-query)
* [Run any SQL query](#run-any-sql-query)
* [Clear cache](#clear-cache)
* [Check version](#check-version)
@ -21,7 +21,7 @@
If you have a local typeorm version, make sure it matches the global version we are going to install.
Install typeorm globally with `npm i -g typeorm`.
You can also chose to use `npx typeorm <params>` for each command if you prefer not having to install it.
You can also choose to use `npx typeorm <params>` for each command if you prefer not having to install it.
### If entities files are in typescript
This CLI tool is written in javascript and to be run on node. If your entity files are in typescript, you will need to transpile them to javascript before using CLI. You may skip this section if you only use javascript.
@ -37,7 +37,7 @@ Add typeorm command under scripts section in package.json
```
"scripts": {
...
"typeorm": "node --require ts-node/register ./node_modules/typeorm/cli.js"
"typeorm": "node --require ts-node/register ./node_modules/typeorm/cli.js"
}
```
@ -79,7 +79,7 @@ Once all dependencies are installed, you need to modify `ormconfig.json` and ins
After that, you can run your application by running `npm start`.
All files are generated in the current directory.
If you want to generate them in a special directory you can use `--name`:
If you want to generate them in a special directory you can use `--name`:
```
typeorm init --name my-project
@ -114,7 +114,7 @@ You can create a new entity using CLI:
typeorm entity:create -n User
```
where `User` is an entity file and class name.
where `User` is an entity file and class name.
Running the command will create a new empty entity in `entitiesDir` of the project.
To setup the `entitiesDir` of the project you must add it in connection options:
@ -130,7 +130,7 @@ Learn more about [connection options](./connection-options.md).
If you have a multi-module project structure with multiple entities in different directories
you can provide the path to the CLI command where you want to generate an entity:
```
typeorm entity:create -n User -d src/user/entity
```
@ -145,7 +145,7 @@ You can create a new subscriber using CLI:
typeorm subscriber:create -n UserSubscriber
```
where `UserSubscriber` is a subscriber file and class name.
where `UserSubscriber` is a subscriber file and class name.
Running the following command will create a new empty subscriber in the `subscribersDir` of the project.
To setup `subscribersDir` you must add it in connection options:
@ -161,7 +161,7 @@ Learn more about [connection options](./connection-options.md).
If you have a multi-module project structure with multiple subscribers in different directories
you can provide a path to the CLI command where you want to generate a subscriber:
```
typeorm subscriber:create -n UserSubscriber -d src/user/subscriber
```
@ -176,7 +176,7 @@ You can create a new migration using CLI:
typeorm migration:create -n UserMigration
```
where `UserMigration` is a migration file and class name.
where `UserMigration` is a migration file and class name.
Running the command will create a new empty migration in the `migrationsDir` of the project.
To setup `migrationsDir` you must add it in connection options:
@ -255,7 +255,7 @@ To synchronize a database schema use:
typeorm schema:sync
```
Be careful running this command in production -
Be careful running this command in production -
schema sync may cause data loss if you don't use it wisely.
Check which sql queries it will run before running on production.
@ -277,9 +277,9 @@ typeorm schema:drop
Be careful with this command on production since it completely removes data from your database.
## Run any sql query
## Run any SQL query
You can execute any sql query you want directly in the database using:
You can execute any SQL query you want directly in the database using:
```
typeorm query "SELECT * FROM USERS"
@ -287,7 +287,7 @@ typeorm query "SELECT * FROM USERS"
## Clear cache
If you are using `QueryBuilder` caching, sometimes you may want to clear everything stored in the cache.
If you are using `QueryBuilder` caching, sometimes you may want to clear everything stored in the cache.
You can do it using the following command:
```

View File

@ -13,7 +13,7 @@
userRepository.find({ select: ["firstName", "lastName"] });
```
- `relations` - 关系需要加载主体。 也可以加载子关系join 和 leftJoinAndSelect 的简写)
- `relations` - 关系需要加载主体。 也可以加载子关系(`join``leftJoinAndSelect` 的简写)
```typescript
userRepository.find({ relations: ["profile", "photos", "videos"] });

View File

@ -7,7 +7,7 @@ import * as yargs from "yargs";
import chalk from "chalk";
/**
* Executes an sql query on the given connection.
* Executes an SQL query on the given connection.
*/
export class QueryCommand implements yargs.CommandModule {
command = "query [query]";

View File

@ -403,17 +403,17 @@ export class Connection {
}
/**
* Creates a new query builder that can be used to build a sql query.
* Creates a new query builder that can be used to build a SQL query.
*/
createQueryBuilder<Entity>(entityClass: EntityTarget<Entity>, alias: string, queryRunner?: QueryRunner): SelectQueryBuilder<Entity>;
/**
* Creates a new query builder that can be used to build a sql query.
* Creates a new query builder that can be used to build a SQL query.
*/
createQueryBuilder(queryRunner?: QueryRunner): SelectQueryBuilder<any>;
/**
* Creates a new query builder that can be used to build a sql query.
* Creates a new query builder that can be used to build a SQL query.
*/
createQueryBuilder<Entity>(entityOrRunner?: EntityTarget<Entity>|QueryRunner, alias?: string, queryRunner?: QueryRunner): SelectQueryBuilder<Entity> {
if (this instanceof MongoEntityManager)

View File

@ -163,17 +163,17 @@ export class EntityManager {
}
/**
* Creates a new query builder that can be used to build a sql query.
* Creates a new query builder that can be used to build a SQL query.
*/
createQueryBuilder<Entity>(entityClass: EntityTarget<Entity>, alias: string, queryRunner?: QueryRunner): SelectQueryBuilder<Entity>;
/**
* Creates a new query builder that can be used to build a sql query.
* Creates a new query builder that can be used to build a SQL query.
*/
createQueryBuilder(queryRunner?: QueryRunner): SelectQueryBuilder<any>;
/**
* Creates a new query builder that can be used to build a sql query.
* Creates a new query builder that can be used to build a SQL query.
*/
createQueryBuilder<Entity>(entityClass?: EntityTarget<Entity>|QueryRunner, alias?: string, queryRunner?: QueryRunner): SelectQueryBuilder<Entity> {
if (alias) {

View File

@ -31,7 +31,7 @@ export class DeleteQueryBuilder<Entity> extends QueryBuilder<Entity> implements
// -------------------------------------------------------------------------
/**
* Gets generated sql query without parameters being replaced.
* Gets generated SQL query without parameters being replaced.
*/
getQuery(): string {
let sql = this.createComment();

View File

@ -30,7 +30,7 @@ export class InsertQueryBuilder<Entity> extends QueryBuilder<Entity> {
// -------------------------------------------------------------------------
/**
* Gets generated sql query without parameters being replaced.
* Gets generated SQL query without parameters being replaced.
*/
getQuery(): string {
let sql = this.createComment();

View File

@ -113,7 +113,7 @@ export abstract class QueryBuilder<Entity> {
// -------------------------------------------------------------------------
/**
* Gets generated sql query without parameters being replaced.
* Gets generated SQL query without parameters being replaced.
*/
abstract getQuery(): string;

View File

@ -15,7 +15,7 @@ export class RelationQueryBuilder<Entity> extends QueryBuilder<Entity> {
// -------------------------------------------------------------------------
/**
* Gets generated sql query without parameters being replaced.
* Gets generated SQL query without parameters being replaced.
*/
getQuery(): string {
return "";

View File

@ -49,7 +49,7 @@ export class SelectQueryBuilder<Entity> extends QueryBuilder<Entity> implements
// -------------------------------------------------------------------------
/**
* Gets generated sql query without parameters being replaced.
* Gets generated SQL query without parameters being replaced.
*/
getQuery(): string {
let sql = this.createComment();

View File

@ -39,7 +39,7 @@ export class SoftDeleteQueryBuilder<Entity> extends QueryBuilder<Entity> impleme
// -------------------------------------------------------------------------
/**
* Gets generated sql query without parameters being replaced.
* Gets generated SQL query without parameters being replaced.
*/
getQuery(): string {
let sql = this.createUpdateExpression();

View File

@ -41,7 +41,7 @@ export class UpdateQueryBuilder<Entity> extends QueryBuilder<Entity> implements
// -------------------------------------------------------------------------
/**
* Gets generated sql query without parameters being replaced.
* Gets generated SQL query without parameters being replaced.
*/
getQuery(): string {
let sql = this.createComment();

View File

@ -60,7 +60,7 @@ export class AbstractRepository<Entity extends ObjectLiteral> {
// -------------------------------------------------------------------------
/**
* Creates a new query builder for the repository's entity that can be used to build a sql query.
* Creates a new query builder for the repository's entity that can be used to build a SQL query.
* If current repository does not manage any entity, then exception will be thrown.
*/
protected createQueryBuilder(alias: string): SelectQueryBuilder<Entity> {
@ -72,7 +72,7 @@ export class AbstractRepository<Entity extends ObjectLiteral> {
}
/**
* Creates a new query builder for the given entity that can be used to build a sql query.
* Creates a new query builder for the given entity that can be used to build a SQL query.
*/
protected createQueryBuilderFor<T>(entity: ObjectType<T>, alias: string): SelectQueryBuilder<T> {
return this.getRepositoryFor(entity).createQueryBuilder(alias);

View File

@ -127,7 +127,7 @@ export class BaseEntity {
}
/**
* Creates a new query builder that can be used to build a sql query.
* Creates a new query builder that can be used to build a SQL query.
*/
static createQueryBuilder<T extends BaseEntity>(this: ObjectType<T>, alias?: string): SelectQueryBuilder<T> {
return (this as any).getRepository().createQueryBuilder(alias);
@ -255,7 +255,7 @@ export class BaseEntity {
* Unlike save method executes a primitive operation without cascades, relations and other operations included.
* Executes fast and efficient INSERT ... ON CONFLICT DO UPDATE/ON DUPLICATE KEY UPDATE query.
*/
static upsert<T extends BaseEntity>(this: ObjectType<T> & typeof BaseEntity,
static upsert<T extends BaseEntity>(this: ObjectType<T> & typeof BaseEntity,
entityOrEntities: QueryDeepPartialEntity<T> | (QueryDeepPartialEntity<T>[]),
conflictPathsOrOptions: string[] | UpsertOptions<T>): Promise<InsertResult> {
return this.getRepository<T>().upsert(entityOrEntities, conflictPathsOrOptions);

View File

@ -45,7 +45,7 @@ export class Repository<Entity extends ObjectLiteral> {
// -------------------------------------------------------------------------
/**
* Creates a new query builder that can be used to build a sql query.
* Creates a new query builder that can be used to build a SQL query.
*/
createQueryBuilder(alias?: string, queryRunner?: QueryRunner): SelectQueryBuilder<Entity> {
return this.manager.createQueryBuilder<Entity>(this.metadata.target as any, alias || this.metadata.targetName, queryRunner || this.queryRunner);