Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: types for findAndCountAll #372

Merged
merged 3 commits into from
Dec 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/adapters/sequelize.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ export class SequelizeBone extends AbstractBone {
static findAll<T extends typeof SequelizeBone>(this: T, options?: SequelizeConditions<T>): Spell<T, Collection<InstanceType<T>>>;
static find<T extends typeof SequelizeBone>(this: T, options?: SequelizeConditions<T>): Spell<T, InstanceType<T> | null>;
static findAndCountAll<T extends typeof SequelizeBone>(this: T, options?: SequelizeConditions<T>): Promise<{
rows: Array<typeof SequelizeBone>,
rows: Array<InstanceType<T>>,
count: number,
}>

Expand Down
5 changes: 3 additions & 2 deletions test/types/sequelize.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -586,6 +586,7 @@ describe('=> sequelize (TypeScript)', function() {
});
assert.equal(rows.length, 1);
assert.equal(count, 1);
assert.equal(rows[0].title, 'Leah');

// with limit
const { rows: rows1, count: count1 } = await Post.findAndCountAll({
Expand All @@ -597,8 +598,7 @@ describe('=> sequelize (TypeScript)', function() {
});

assert.equal(rows1.length, 0);
assert.equal(count1, 1);

assert.equal(count1, 1);
//ignore attributes

const { rows: rows2, count: count2 } = await Post.findAndCountAll({
Expand Down Expand Up @@ -632,6 +632,7 @@ describe('=> sequelize (TypeScript)', function() {
});
assert.equal(rows.length, 1);
assert.equal(count, 1);
assert.equal(rows[0].title, 'Leah');
});
});

Expand Down