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

How can i use honohub with cloudflare d1? #10

Open
Stead08 opened this issue Aug 14, 2024 · 4 comments
Open

How can i use honohub with cloudflare d1? #10

Stead08 opened this issue Aug 14, 2024 · 4 comments
Assignees
Labels
enhancement New feature or request

Comments

@Stead08
Copy link

Stead08 commented Aug 14, 2024

I want to use Cloudflare D1 with HonoHub, but I need to access the database from the Hono context.
With the initialization:

const app = new Hono();
app.route("/", createHub(hubConfig));

I cannot use the context, so I cannot access the database.
Is there any good solution?
Thanks

@MathurAditya724 MathurAditya724 self-assigned this Aug 15, 2024
@MathurAditya724 MathurAditya724 added the enhancement New feature or request label Aug 15, 2024
@Stead08 Stead08 closed this as completed Aug 17, 2024
@MathurAditya724
Copy link
Member

MathurAditya724 commented Aug 17, 2024

Hey! were you able to solve this?

@Stead08
Copy link
Author

Stead08 commented Aug 17, 2024

I don't expect this to be implemented as a new feature, so I have closed the issue.

@MathurAditya724
Copy link
Member

I am aware of a method to use D1 with HonoHub, but it's not my preferred approach. However, I do believe it's important to provide a solution. I'll reopen this issue to ensure we implement either a function or an example to make HonoHub work seamlessly with D1.

@MiguelsPizza
Copy link

MiguelsPizza commented Sep 29, 2024

Also interested in D1 support. Maybe default to D1 if one of the bindings pass in extends the abstract class?

declare abstract class D1Database {
  prepare(query: string): D1PreparedStatement;
  dump(): Promise<ArrayBuffer>;
  batch<T = unknown>(statements: D1PreparedStatement[]): Promise<D1Result<T>[]>;
  exec(query: string): Promise<D1ExecResult>;
}

A declarative approach might be better though

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

No branches or pull requests

4 participants
@MathurAditya724 @Stead08 @MiguelsPizza and others