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

explicit return/callback type for update based on options #44

Merged
merged 1 commit into from
Jan 11, 2024

Conversation

RobMayer
Copy link

@RobMayer RobMayer commented Jul 7, 2023

No description provided.

@tex0l tex0l requested a review from arantes555 January 10, 2024 15:33
Copy link

@arantes555 arantes555 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello @RobMayer . Thank you for the PR, and sorry for the delay in reviewing it !

Could you please explain concretely what is the interest of this ? I have trouble coming up with an actual case where this would change anything, but I am sure I am missing something.

@tex0l tex0l merged commit 1eeda8f into seald:master Jan 11, 2024
@RobMayer
Copy link
Author

Hello @RobMayer . Thank you for the PR, and sorry for the delay in reviewing it !

Could you please explain concretely what is the interest of this ? I have trouble coming up with an actual case where this would change anything, but I am sure I am missing something.

It looks like this got merged, but to still answer the question:
the payload type of "db" will be something called "Payload" for the sake of argument.

// before
const resultSingle = await db.updateAsync({...}, { multi: false });
resultSingle.affectedDocument // the type of this is "null | Payload | Payload[]

const resultMulti = await db.updateAsync({...}, { multi: true });
resultMulti.affectedDocument // the type of this is "null | Payload | Payload[]

// after
const resultSingle = await db.updateAsync({...}, { multi: false });
resultSingle.affectedDocument // the type of this is "null | Payload"

const resultMulti = await db.updateAsync({...}, { multi: true });
resultMulti.affectedDocument // the type of this is "Payload[]"

basically: it's more explicit on the type of affectedDocument based on wether you set multi to true or not without having to narrow the type each and every time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants