Skip to content

Commit 8f5db77

Browse files
committed
feat: add partial
1 parent f4e68f3 commit 8f5db77

File tree

8 files changed

+45
-23
lines changed

8 files changed

+45
-23
lines changed

.prettierrc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
{
2+
"tabWidth": 2,
3+
"printWidth": 80,
24
"singleQuote": true,
3-
"trailingComma": "all",
5+
"trailingComma": "none",
46
"semi": false
57
}

src/protocols/filter/comparator-operator-enum.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,5 @@ export enum ComparatorOperatorEnum {
1616
OP_AND = 'OP_AND',
1717
OP_NOT = 'OP_NOT',
1818
OP_NOR = 'OP_NOR',
19-
OP_OR = 'OP_OR',
19+
OP_OR = 'OP_OR'
2020
}

src/protocols/filter/comparator.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export class Comparator {
1010
private readonly _operator: ComparatorOperatorEnum,
1111
private readonly _key: string,
1212
private readonly _value: any | any[],
13-
private readonly _options?: OptionsComparator,
13+
private readonly _options?: OptionsComparator
1414
) {}
1515

1616
get operator(): ComparatorOperatorEnum {
@@ -48,7 +48,7 @@ export class Comparator {
4848
operator: ComparatorOperatorEnum,
4949
key: string,
5050
value: any | any[],
51-
options?: OptionsComparator,
51+
options?: OptionsComparator
5252
): Comparator => {
5353
return new Comparator(operator, key, value, options)
5454
}
@@ -83,7 +83,7 @@ export class Comparator {
8383
static in = (
8484
key: string,
8585
value: any[],
86-
options?: OptionsFilter,
86+
options?: OptionsFilter
8787
): Comparator =>
8888
Comparator.builder(ComparatorOperatorEnum.IN, key, value, options)
8989

src/protocols/filter/filter.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export class Filter {
1414

1515
private addCommand(
1616
comparator: Comparator | Comparator[],
17-
operator: LogicalOperatorEnum,
17+
operator: LogicalOperatorEnum
1818
): void {
1919
this._command.push({ comparator, operator })
2020
}

src/protocols/filter/logical-operator-enum.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@ export enum LogicalOperatorEnum {
22
AND = 'AND',
33
NOT = 'NOT',
44
NOR = 'NOR',
5-
OR = 'OR',
5+
OR = 'OR'
66
}

src/protocols/repository/base-entity.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
export interface BaseEntity<T> {
2-
id?: T
2+
id: T
33
ativo?: boolean
44
dataInclusao?: Date
55
dataAtualizacao?: Date
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
export enum DirectionEnum {
22
ASC = 1,
3-
DESC = -1,
3+
DESC = -1
44
}
Lines changed: 34 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,63 +1,83 @@
11
import { ResultPaged } from './result-paged'
22
import { BaseEntity } from './base-entity'
3-
import { Filter } from '../filter/filter'
3+
import { Filter } from '../filter'
44
import { Sort } from './sort'
55

66
export interface Repository<U, T extends BaseEntity<U>> {
77
fieldId(): string
8+
89
fieldVersion(): string
10+
911
fieldCreatedAt(): string
12+
1013
fieldUpdatedAt(): string
14+
1115
fieldActive(): string
16+
1217
find(
1318
filter?: Filter,
1419
populate?: string | string[],
1520
sort?: Sort | Sort[],
1621
includeAll?: boolean,
22+
limit?: number
1723
): Promise<T[]>
24+
1825
findOne(
1926
filter?: Filter,
2027
populate?: string | string[],
2128
sort?: Sort | Sort[],
22-
includeAll?: boolean,
29+
includeAll?: boolean
2330
): Promise<T>
31+
2432
findById(
2533
id: U,
2634
populate?: string | string[],
27-
includeAll?: boolean,
35+
includeAll?: boolean
2836
): Promise<T>
37+
2938
paged(
3039
first?: number,
3140
pageSize?: number,
3241
filter?: Filter,
3342
populate?: string | string[],
3443
sort?: Sort | Sort[],
35-
includeAll?: boolean,
44+
includeAll?: boolean
3645
): Promise<ResultPaged<T>>
37-
insert(doc: T, populate?: string | string[]): Promise<T>
38-
insertMany(docs: T[], populate?: string | string[]): Promise<T[]>
46+
47+
insert(doc: Partial<T>, populate?: string | string[]): Promise<T>
48+
49+
insertMany(docs: Partial<T>[], populate?: string | string[]): Promise<T[]>
50+
3951
update(
4052
id: U,
41-
doc: T,
53+
doc: Partial<T>,
4254
populate?: string | string[],
43-
includeAll?: boolean,
55+
includeAll?: boolean
4456
): Promise<T>
57+
4558
updateMany(
4659
filter: Filter,
47-
doc: T,
60+
doc: Partial<T>[],
4861
populate?: string | string[],
49-
includeAll?: boolean,
62+
includeAll?: boolean
5063
): Promise<T[]>
64+
5165
delete(id: U, includeAll?: boolean): Promise<void>
66+
5267
deleteMany(filter?: Filter, includeAll?: boolean): Promise<void>
68+
5369
exists(filter?: Filter, includeAll?: boolean): Promise<boolean>
70+
5471
upsert(
55-
doc: T,
72+
doc: Partial<T>,
5673
filter?: Filter,
5774
populate?: string | string[],
58-
includeAll?: boolean,
75+
includeAll?: boolean
5976
): Promise<T>
77+
6078
count(filter?: Filter, includeAll?: boolean): Promise<number>
61-
logicDelete(id: U): Promise<void>
62-
logicActive(id: U): Promise<void>
79+
80+
logicDelete(id: U): Promise<T>
81+
82+
logicActive(id: U): Promise<T>
6383
}

0 commit comments

Comments
 (0)