Skip to content
This repository has been archived by the owner on Feb 7, 2023. It is now read-only.

Fix return type of D1PreparedStatement.all #285

Merged
merged 1 commit into from
Oct 6, 2022
Merged

Fix return type of D1PreparedStatement.all #285

merged 1 commit into from
Oct 6, 2022

Conversation

sdnts
Copy link
Contributor

@sdnts sdnts commented Sep 29, 2022

D1Result's generic parameter expects the type of a single item.

The type of result in the code below is D1Result<User[]>

type User = { id: string }
const result = ctx.d1.prepare("SELECT * FROM users").all<User>()

This means that the type of result.results actually ends up being User[][] instead of User[].

@changeset-bot
Copy link

changeset-bot bot commented Sep 29, 2022

🦋 Changeset detected

Latest commit: 0078f5b

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@cloudflare/workers-types Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@sdnts
Copy link
Contributor Author

sdnts commented Sep 30, 2022

cc @mrbbot

Copy link
Contributor

@mrbbot mrbbot left a comment

Choose a reason for hiding this comment

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

Nice! Thanks for the PR! 🙂 Fixes #279.

@mrbbot mrbbot merged commit b6a5d1a into cloudflare:master Oct 6, 2022
@github-actions github-actions bot mentioned this pull request Oct 6, 2022
@sdnts sdnts deleted the siddhant/fix-d1-all branch October 6, 2022 10:04
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants