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

[Feature] ORM Support for Rust Workers #612

Open
1 task done
ChihweiLHBird opened this issue Aug 3, 2024 · 7 comments
Open
1 task done

[Feature] ORM Support for Rust Workers #612

ChihweiLHBird opened this issue Aug 3, 2024 · 7 comments

Comments

@ChihweiLHBird
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

Description

JavaScript workers are capable of Prisma ORM to query Cloudflare D1 database: https://developers.cloudflare.com/d1/tutorials/d1-and-prisma-orm/

It would be very nice to have a similar ORM support in the Rust workers as well.

@Brayan-724
Copy link

Hi @ChihweiLHBird, we (@RustLangES) are planning to do an implementation of an agnostic ORM focused on Cloudflare Workers in Rust. You can follow our progress in this discussion. We are an spanish community, but we accept people who speak any language.

@kflansburg
Copy link
Contributor

We've discussed an integration with something like SQLx, but the API surface that we would need to implement is quite daunting.

@Brayan-724
Copy link

Brayan-724 commented Aug 9, 2024

@kflansburg We already have an experimental ORM for one of our project (The api is not the best). As I said it is so experimental, but we are working on to build a library to extend Cloudflare Workers. It will have a lot of utilities to do the best developer experience.

The same as @ChihweiLHBird, I invite you to our discussion or discord to share us your ideas.

@extraymond
Copy link

While not a full a ORM, I created a PR to allow cornucopia to be used within cloudflare-worker.
Since all the query are build in compile time, the only thing I need to do is allow tokio-postgres to compile in wasm.

cornucopia-rs/cornucopia#256


cornucopia is a SQL first query-builder to generate rust query.

@extraymond
Copy link

Just found this in the sea-orm repo
https://github.com/SeaQL/sea-orm/blob/039e4423d3ef2fe4959c0b19c2b37bbd3f90d9b9/examples/proxy_cloudflare_worker_example/README.md

By creating proxy-backend allows one to use sea-orm that calls D1, maybe the same can be made for postgres that calls the socket.connect without having to rely on sqlx(used by sea-orm) for providing the connection.

@kflansburg
Copy link
Contributor

Just found this in the sea-orm repo https://github.com/SeaQL/sea-orm/blob/039e4423d3ef2fe4959c0b19c2b37bbd3f90d9b9/examples/proxy_cloudflare_worker_example/README.md

By creating proxy-backend allows one to use sea-orm that calls D1, maybe the same can be made for postgres that calls the socket.connect without having to rely on sqlx(used by sea-orm) for providing the connection.

This does look like a pretty simple interface to implement. I haven't used Sea ORM. Pulling this in for D1, as well as supporting Hyperdrive (behind a crate feature) seems pretty interesting.

@Upbolt
Copy link

Upbolt commented Nov 20, 2024

this is an issue i first posted @ SeaQL/sea-query#838, but i'll just copy over the contents here in case it has any relevance

trying to use cloudflare d1 with sea-orm through the example proxy integration, but

https://github.com/SeaQL/sea-orm/blob/5f1a9d2a46c9b0776c57311782e72dab8e5c6948/examples/proxy_cloudflare_worker_example/src/orm.rs#L63-L97

null values hit the _ case since internally D1Result::results() returns a javascript array which will treat null values as their own type when deserialized through serde, making it incompatible with sea-query's Value enum, which requires to know the type ahead of time

https://github.com/SeaQL/sea-query/blob/b91ba14f680e11a2e813880b775299a44d279c66/src/value.rs#L127-L216

is there a reasonable way to accommodate for this?

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

No branches or pull requests

5 participants