From 9a54f2223ffec99218a6dea40e65f6f4b8a1c83a Mon Sep 17 00:00:00 2001 From: Jerod King Date: Fri, 21 Jul 2017 22:34:34 -0700 Subject: [PATCH] Fixing findOrCreate and findCreateFind 1) Fixing findOrCreate to allow any values or a specific interface A. This matches the findOrBuild definition. 2) Fixing findCreateFind to return the correct value [Model, boolean], and also apply the same fix as #1. --- lib/models/Model.d.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/models/Model.d.ts b/lib/models/Model.d.ts index ba899061..2344f8ec 100644 --- a/lib/models/Model.d.ts +++ b/lib/models/Model.d.ts @@ -327,14 +327,16 @@ export declare class Model extends Hooks { * an instance of sequelize.TimeoutError will be thrown instead. If a transaction is created, a savepoint * will be created instead, and any unique constraint violation will be handled internally. */ - static findOrCreate>(options: IFindOrInitializeOptions): Promise<[T, boolean]>; - + static findOrCreate>(options: IFindOrInitializeOptions): Promise<[T, boolean]>; + static findOrCreate, A>(options: IFindOrInitializeOptions): Promise<[T, boolean]>; + /** * A more performant findOrCreate that will not work under a transaction (at least not in postgres) * Will execute a find call, if empty then attempt to create, if unique constraint then attempt to find again */ - static findCreateFind>(options: IFindCreateFindOptions): Promise; - + static findCreateFind>(options: IFindCreateFindOptions): Promise<[T, boolean]>; + static findCreateFind, A>(options: IFindCreateFindOptions): Promise<[T, boolean]>; + /** * Insert or update a single row. An update will be executed if a row which matches the supplied values on * either the primary key or a unique key is found. Note that the unique index must be defined in your