workers-rs icon indicating copy to clipboard operation
workers-rs copied to clipboard

[Feature] D1 Support

Open vidiabtc opened this issue 2 years ago • 9 comments

Is there an existing issue for this?

  • [X] I have searched the existing issues

Description

It would be great if workers-rs had the functionality of wrangler@d1. Although I understand that it may not be the best time to do this as D1 is still in private beta, but it would be cool if the D1 integration was ready to go by the time D1 is public!

vidiabtc avatar Sep 05 '22 21:09 vidiabtc

I would also be interested in this. I'm also aware that the current state of D1 is in private beta so it may not be doable at the moment.

So I am curious if it is possible to have a worker using both Rust and Typescript in the meanwhile? Where the D1 code is located in Typescript and the main worker code in Rust.

Yrlish avatar Sep 19 '22 08:09 Yrlish

So I am curious if it is possible to have a worker using both Rust and Typescript in the meanwhile? Where the D1 code is located in Typescript and the main worker code in Rust.

It is possible, but it's a bit messy. You can use wasm-bindgen snippets generated from TypeScript and then call it from your Rust or you avoid using worker-build and use esbuild yourself to bundle in some JavaScript that you do your D1 calls in. In the future I think we'll have to figure out how we're going to go about private-beta bindings, possible through an unstable feature flag?

Until then, D1 support is probably off the table for now.

zebp avatar Sep 19 '22 13:09 zebp

In the future I think we'll have to figure out how we're going to go about private-beta bindings, possible through an unstable feature flag?

Yeah this sounds like a good idea, some sort of unstable branch for non-GA features.

I was also thinking of an alternative solution. Having two separate workers, one in Rust and one "normal" in Typescript and connecting them via a service binding. This would mean having to transfer stuff between them though.

Yrlish avatar Sep 19 '22 13:09 Yrlish

it is now open alpha ╰(°▽°)╯

yzn-h avatar Dec 02 '22 10:12 yzn-h

So do we have an status update on this?

Yrlish avatar Jan 05 '23 12:01 Yrlish

https://github.com/cloudflare/workers-rs/pull/246

KianNH avatar Jan 05 '23 12:01 KianNH

#270

Keavon avatar May 10 '23 16:05 Keavon

I can't enable d1 feature but I have seen this commit that not released in 0.0.17. Any updates?

spicyzboss avatar Aug 02 '23 18:08 spicyzboss

I can't enable d1 feature but I have seen this commit that not released in 0.0.17. Any updates?

It's been released as of 0.0.18:

worker = {version = "0.0.18", features = ["d1"] }

dev-ardi avatar Sep 26 '23 17:09 dev-ardi