Skip to content

Commit

Permalink
feat: increase query performance and add fail option
Browse files Browse the repository at this point in the history
  • Loading branch information
etienne-bechara committed Apr 23, 2021
1 parent 3b4e343 commit 97324eb
Show file tree
Hide file tree
Showing 6 changed files with 130 additions and 112 deletions.
20 changes: 9 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,17 +123,15 @@ export class UserService extends OrmService<UserEntity> {

At this point, you may inject you `UserService` in any order provider and have its methods available to you:
```ts
readById(id: string, options: OrmReadOptions<Entity> = { }): Entity

readUnique(params: OrmReadParams<Entity>, options: OrmReadOptions<Entity> = { }): Entity

readAndCount(params: OrmReadParams<Entity>, options: OrmReadOptions<Entity> = { }): OrmPaginatedResponse<Entity>

updateById(id: string, data: EntityData<Entity>): Entity

resert(data: EntityData<Entity>, uniqueKey?: string[]): Entity

upsert(data: EntityData<Entity>, uniqueKey?: string[]): Entity
readById(id: string, options: OrmReadOptions<Entity> = { }): Entity;
readByIdOrFail(id: string, options: OrmReadOptions<Entity> = { }): Entity;
readUnique(params: OrmReadParams<Entity>, options: OrmReadOptions<Entity> = { }): Entity;
readUniqueOrFail(params: OrmReadParams<Entity>, options: OrmReadOptions<Entity> = { }): Entity;
readAndCount(params: OrmReadParams<Entity>, options: OrmReadOptions<Entity> = { }): OrmPaginatedResponse<Entity>;
updateById(id: string, data: EntityData<Entity>): Entity;
removeById(id: string): Entity;
resert(data: EntityData<Entity>, uniqueKey?: string[]): Entity;
upsert(data: EntityData<Entity>, uniqueKey?: string[]): Entity;
```

### Creating an Entity Controller
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
},
"devDependencies": {
"@bechara/eslint-config-bechara-ts": "1.1.3",
"@bechara/nestjs-core": "2.0.17",
"@bechara/nestjs-core": "2.0.19",
"@commitlint/cli": "12.1.1",
"@commitlint/config-conventional": "12.1.1",
"@mikro-orm/mysql": "4.5.3",
Expand Down
107 changes: 48 additions & 59 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions source/orm/orm.interface/orm.read.options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ import { OrmQueryOrder } from '../orm.enum';
export interface OrmReadOptions<Entity> extends FindOptions<Entity> {
sort?: string;
order?: OrmQueryOrder;
findOrFail?: boolean;
}
4 changes: 3 additions & 1 deletion source/orm/orm.interface/orm.upsert.options.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
export interface OrmUpsertOptions {
import { OrmReadOptions } from './orm.read.options';

export interface OrmUpsertOptions<Entity> extends OrmReadOptions<Entity> {
uniqueKey?: string[];
allowUpdate?: boolean;
disallowRetry?: boolean;
Expand Down
Loading

0 comments on commit 97324eb

Please sign in to comment.