Skip to content

Commit 84df168

Browse files
committed
feat: add newly added findByPk method to model
1 parent f32750d commit 84df168

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

lib/model.d.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1661,6 +1661,16 @@ export abstract class Model {
16611661
identifier: number | string,
16621662
options: NonNullFindOptions
16631663
): Promise<M>
1664+
public static findByPk<M extends Model>(
1665+
this: { new (): M } & typeof Model,
1666+
identifier?: number | string,
1667+
options?: FindOptions
1668+
): Promise<M | null>
1669+
public static findByPk<M extends Model>(
1670+
this: { new (): M } & typeof Model,
1671+
identifier: number | string,
1672+
options: NonNullFindOptions
1673+
): Promise<M>
16641674

16651675
/**
16661676
* Search for a single instance. This applies LIMIT 1, so the listener will always be called with a single

test/usage.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,5 @@ async function test(): Promise<void> {
1717

1818
const user2 = await User.create({ firstName: 'John', groupId: 1 })
1919
await User.findAndCountAll({ distinct: true })
20+
await User.findByPk(1)
2021
}

0 commit comments

Comments
 (0)