Skip to content

Commit

Permalink
fix: Improve Service typings for DB Common API (#1838)
Browse files Browse the repository at this point in the history
Related #1567
  • Loading branch information
deskoh committed Apr 11, 2020
1 parent 95eb447 commit 5a87bd0
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions packages/adapter-commons/src/service.ts
Expand Up @@ -97,6 +97,10 @@ export class AdapterService<T = any> implements ServiceMethods<T> {
return callMethod(this, '_get', id, params);
}

create (data: Partial<T>, params?: Params): Promise<T>;

create (data: Partial<T>[], params?: Params): Promise<T[]>;

create (data: Partial<T> | Partial<T>[], params?: Params): Promise<T | T[]> {
if (Array.isArray(data) && !this.allowsMulti('create')) {
return Promise.reject(new MethodNotAllowed(`Can not create multiple entries`));
Expand All @@ -115,6 +119,10 @@ export class AdapterService<T = any> implements ServiceMethods<T> {
return callMethod(this, '_update', id, data, params);
}

patch (id: Id, data: Partial<T>, params?: Params): Promise<T>;

patch (id: null, data: Partial<T>, params?: Params): Promise<T[]>;

patch (id: NullableId, data: Partial<T>, params?: Params): Promise<T | T[]> {
if (id === null && !this.allowsMulti('patch')) {
return Promise.reject(new MethodNotAllowed(`Can not patch multiple entries`));
Expand All @@ -123,6 +131,10 @@ export class AdapterService<T = any> implements ServiceMethods<T> {
return callMethod(this, '_patch', id, data, params);
}

remove (id: Id, params?: Params): Promise<T>;

remove (id: null, params?: Params): Promise<T[]>;

remove (id: NullableId, params?: Params): Promise<T | T[]> {
if (id === null && !this.allowsMulti('remove')) {
return Promise.reject(new MethodNotAllowed(`Can not remove multiple entries`));
Expand Down

0 comments on commit 5a87bd0

Please sign in to comment.