Skip to content

Commit

Permalink
Merge pull request #3 from repofy/develop
Browse files Browse the repository at this point in the history
feat: add partial
  • Loading branch information
tiagompalte authored Dec 28, 2021
2 parents 5e38ee3 + 8f5db77 commit ff27dae
Show file tree
Hide file tree
Showing 8 changed files with 45 additions and 23 deletions.
4 changes: 3 additions & 1 deletion .prettierrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
{
"tabWidth": 2,
"printWidth": 80,
"singleQuote": true,
"trailingComma": "all",
"trailingComma": "none",
"semi": false
}
2 changes: 1 addition & 1 deletion src/protocols/filter/comparator-operator-enum.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@ export enum ComparatorOperatorEnum {
OP_AND = 'OP_AND',
OP_NOT = 'OP_NOT',
OP_NOR = 'OP_NOR',
OP_OR = 'OP_OR',
OP_OR = 'OP_OR'
}
6 changes: 3 additions & 3 deletions src/protocols/filter/comparator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export class Comparator {
private readonly _operator: ComparatorOperatorEnum,
private readonly _key: string,
private readonly _value: any | any[],
private readonly _options?: OptionsComparator,
private readonly _options?: OptionsComparator
) {}

get operator(): ComparatorOperatorEnum {
Expand Down Expand Up @@ -48,7 +48,7 @@ export class Comparator {
operator: ComparatorOperatorEnum,
key: string,
value: any | any[],
options?: OptionsComparator,
options?: OptionsComparator
): Comparator => {
return new Comparator(operator, key, value, options)
}
Expand Down Expand Up @@ -83,7 +83,7 @@ export class Comparator {
static in = (
key: string,
value: any[],
options?: OptionsFilter,
options?: OptionsFilter
): Comparator =>
Comparator.builder(ComparatorOperatorEnum.IN, key, value, options)

Expand Down
2 changes: 1 addition & 1 deletion src/protocols/filter/filter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export class Filter {

private addCommand(
comparator: Comparator | Comparator[],
operator: LogicalOperatorEnum,
operator: LogicalOperatorEnum
): void {
this._command.push({ comparator, operator })
}
Expand Down
2 changes: 1 addition & 1 deletion src/protocols/filter/logical-operator-enum.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ export enum LogicalOperatorEnum {
AND = 'AND',
NOT = 'NOT',
NOR = 'NOR',
OR = 'OR',
OR = 'OR'
}
2 changes: 1 addition & 1 deletion src/protocols/repository/base-entity.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export interface BaseEntity<T> {
id?: T
id: T
ativo?: boolean
dataInclusao?: Date
dataAtualizacao?: Date
Expand Down
2 changes: 1 addition & 1 deletion src/protocols/repository/direction-enum.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export enum DirectionEnum {
ASC = 1,
DESC = -1,
DESC = -1
}
48 changes: 34 additions & 14 deletions src/protocols/repository/repository.ts
Original file line number Diff line number Diff line change
@@ -1,63 +1,83 @@
import { ResultPaged } from './result-paged'
import { BaseEntity } from './base-entity'
import { Filter } from '../filter/filter'
import { Filter } from '../filter'
import { Sort } from './sort'

export interface Repository<U, T extends BaseEntity<U>> {
fieldId(): string

fieldVersion(): string

fieldCreatedAt(): string

fieldUpdatedAt(): string

fieldActive(): string

find(
filter?: Filter,
populate?: string | string[],
sort?: Sort | Sort[],
includeAll?: boolean,
limit?: number
): Promise<T[]>

findOne(
filter?: Filter,
populate?: string | string[],
sort?: Sort | Sort[],
includeAll?: boolean,
includeAll?: boolean
): Promise<T>

findById(
id: U,
populate?: string | string[],
includeAll?: boolean,
includeAll?: boolean
): Promise<T>

paged(
first?: number,
pageSize?: number,
filter?: Filter,
populate?: string | string[],
sort?: Sort | Sort[],
includeAll?: boolean,
includeAll?: boolean
): Promise<ResultPaged<T>>
insert(doc: T, populate?: string | string[]): Promise<T>
insertMany(docs: T[], populate?: string | string[]): Promise<T[]>

insert(doc: Partial<T>, populate?: string | string[]): Promise<T>

insertMany(docs: Partial<T>[], populate?: string | string[]): Promise<T[]>

update(
id: U,
doc: T,
doc: Partial<T>,
populate?: string | string[],
includeAll?: boolean,
includeAll?: boolean
): Promise<T>

updateMany(
filter: Filter,
doc: T,
doc: Partial<T>[],
populate?: string | string[],
includeAll?: boolean,
includeAll?: boolean
): Promise<T[]>

delete(id: U, includeAll?: boolean): Promise<void>

deleteMany(filter?: Filter, includeAll?: boolean): Promise<void>

exists(filter?: Filter, includeAll?: boolean): Promise<boolean>

upsert(
doc: T,
doc: Partial<T>,
filter?: Filter,
populate?: string | string[],
includeAll?: boolean,
includeAll?: boolean
): Promise<T>

count(filter?: Filter, includeAll?: boolean): Promise<number>
logicDelete(id: U): Promise<void>
logicActive(id: U): Promise<void>

logicDelete(id: U): Promise<T>

logicActive(id: U): Promise<T>
}

0 comments on commit ff27dae

Please sign in to comment.