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

Need instructions for existing workers #15343

Closed
rampatra opened this issue Jun 26, 2024 · 1 comment
Closed

Need instructions for existing workers #15343

rampatra opened this issue Jun 26, 2024 · 1 comment
Assignees
Labels
content:edit Request for content edits documentation Documentation edits product:d1 D1: https://developers.cloudflare.com/d1/

Comments

@rampatra
Copy link

Existing documentation URL(s)

Doc link - https://developers.cloudflare.com/d1/get-started/

This page lists nicely the steps when creating a worker from scratch but what if someone already has a worker defined and set up and are adding the D1 database to it. What node dependency to add, etc. can be mentioned.

For example, I have a nextjs app set up already and I want to add D1 database to it. So, how shall I do that?

Currently, the below is giving me an error (D1Database not found):

export interface Env {
    // If you set another name in wrangler.toml as the value for 'binding',
    // replace "DB" with the variable name you defined.
    DB: D1Database;
}

I ran this too npm install @cloudflare/workers-types @cloudflare/d1 but no luck.

What changes are you suggesting?

It should contain steps to do for existing worker.

Additional information

No response

@rampatra rampatra added content:edit Request for content edits documentation Documentation edits labels Jun 26, 2024
@github-actions github-actions bot added the product:d1 D1: https://developers.cloudflare.com/d1/ label Jun 26, 2024
@kodster28 kodster28 assigned Oxyjun and unassigned Maddy-Cloudflare Sep 17, 2024
@Oxyjun
Copy link
Contributor

Oxyjun commented Nov 19, 2024

This issue will be closed when this PR #17923 is merged in.

The PR adds a note to direct users with existing D1 database + Worker to start from step 3.

Note: The steps of adding a D1 database to an existing database is exactly the same as the steps outlined in the page. The specific error above may have originated from the binding name (e.g. "DB") not matching what it's being called in the code itself (e.g. the code will likely have to reference env.DB).

@Oxyjun Oxyjun closed this as completed Nov 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
content:edit Request for content edits documentation Documentation edits product:d1 D1: https://developers.cloudflare.com/d1/
Projects
None yet
Development

No branches or pull requests

7 participants