From ed8189c1b58c5c711b37a17e316cdf32d215da63 Mon Sep 17 00:00:00 2001 From: Ashot Nazaryan Date: Thu, 5 Oct 2023 03:16:38 -0700 Subject: [PATCH] fix: allow _patch to modify the entire base schema --- packages/knex/src/adapter.ts | 8 ++++---- packages/memory/src/index.ts | 8 ++++---- packages/mongodb/src/adapter.ts | 8 ++++---- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/packages/knex/src/adapter.ts b/packages/knex/src/adapter.ts index f31203dcf6..db2e05fd69 100644 --- a/packages/knex/src/adapter.ts +++ b/packages/knex/src/adapter.ts @@ -254,12 +254,12 @@ export class KnexAdapter< }) } - async _patch(id: null, data: PatchData, params?: ServiceParams): Promise - async _patch(id: Id, data: PatchData, params?: ServiceParams): Promise - async _patch(id: NullableId, data: PatchData, _params?: ServiceParams): Promise + async _patch(id: null, data: PatchData | Partial, params?: ServiceParams): Promise + async _patch(id: Id, data: PatchData | Partial, params?: ServiceParams): Promise + async _patch(id: NullableId, data: PatchData | Partial, _params?: ServiceParams): Promise async _patch( id: NullableId, - raw: PatchData, + raw: PatchData | Partial, params: ServiceParams = {} as ServiceParams ): Promise { if (id === null && !this.allowsMulti('patch', params)) { diff --git a/packages/memory/src/index.ts b/packages/memory/src/index.ts index f9d385afee..fd90f17b49 100644 --- a/packages/memory/src/index.ts +++ b/packages/memory/src/index.ts @@ -178,12 +178,12 @@ export class MemoryAdapter< return this._get(id, params) } - async _patch(id: null, data: PatchData, params?: ServiceParams): Promise - async _patch(id: Id, data: PatchData, params?: ServiceParams): Promise - async _patch(id: NullableId, data: PatchData, _params?: ServiceParams): Promise + async _patch(id: null, data: PatchData | Partial, params?: ServiceParams): Promise + async _patch(id: Id, data: PatchData | Partial, params?: ServiceParams): Promise + async _patch(id: NullableId, data: PatchData | Partial, _params?: ServiceParams): Promise async _patch( id: NullableId, - data: PatchData, + data: PatchData | Partial, params: ServiceParams = {} as ServiceParams ): Promise { if (id === null && !this.allowsMulti('patch', params)) { diff --git a/packages/mongodb/src/adapter.ts b/packages/mongodb/src/adapter.ts index 4461b5d52b..7112890b1b 100644 --- a/packages/mongodb/src/adapter.ts +++ b/packages/mongodb/src/adapter.ts @@ -301,12 +301,12 @@ export class MongoDbAdapter< return promise.then(select(params, this.id)).catch(errorHandler) } - async _patch(id: null, data: PatchData, params?: ServiceParams): Promise - async _patch(id: AdapterId, data: PatchData, params?: ServiceParams): Promise - async _patch(id: NullableAdapterId, data: PatchData, _params?: ServiceParams): Promise + async _patch(id: null, data: PatchData | Partial, params?: ServiceParams): Promise + async _patch(id: AdapterId, data: PatchData | Partial, params?: ServiceParams): Promise + async _patch(id: NullableAdapterId, data: PatchData | Partial, _params?: ServiceParams): Promise async _patch( id: NullableAdapterId, - _data: PatchData, + _data: PatchData | Partial, params: ServiceParams = {} as ServiceParams ): Promise { if (id === null && !this.allowsMulti('patch', params)) {