How can i use d1 locally(for test) on sveltekit?
I use sveltekit on cloudflare(with cloudflare adapter). Recently i fall in love on cloudflare serverless echo system.
I want to test my code on dev mode but evnet.platform is always undefined.
run script:
result:
--compatibility-date=2023-07-06
How can i use d1 locally?
refer:
I want to test my code on dev mode but evnet.platform is always undefined.
run script:
npx wrangler pages dev --local --d1=DB -- npm run devnpx wrangler pages dev --local --d1=DB -- npm run devresult:
> npx wrangler pages dev --local --d1=DB -- npm run dev
Running npm run dev...
Sleeping 5 seconds to allow proxy process to start before attempting to automatically determine port...
To skip, specify the proxy port with --proxy.
[proxy]:
> cozyimg@0.0.1 dev
> vite dev
[proxy]:
VITE v4.3.9 ready in 602 ms
[proxy]: ➜ Local: http://localhost:5173/
➜ Network: use --host to expose
[proxy]: {
cookies: {
get: [Function: get],
getAll: [Function: getAll],
set: [Function: set],
delete: [Function: delete],
serialize: [Function: serialize]
},
fetch: [AsyncFunction (anonymous)],
getClientAddress: [Function: getClientAddress],
locals: {},
params: {},
platform: undefined,
}
Automatically determined the proxy port to be 5173.
▲ [WARNING] No compatibility_date was specified. Using today's date: 2023-07-06.
Pass it in your terminal:> npx wrangler pages dev --local --d1=DB -- npm run dev
Running npm run dev...
Sleeping 5 seconds to allow proxy process to start before attempting to automatically determine port...
To skip, specify the proxy port with --proxy.
[proxy]:
> cozyimg@0.0.1 dev
> vite dev
[proxy]:
VITE v4.3.9 ready in 602 ms
[proxy]: ➜ Local: http://localhost:5173/
➜ Network: use --host to expose
[proxy]: {
cookies: {
get: [Function: get],
getAll: [Function: getAll],
set: [Function: set],
delete: [Function: delete],
serialize: [Function: serialize]
},
fetch: [AsyncFunction (anonymous)],
getClientAddress: [Function: getClientAddress],
locals: {},
params: {},
platform: undefined,
}
Automatically determined the proxy port to be 5173.
▲ [WARNING] No compatibility_date was specified. Using today's date: 2023-07-06.
Pass it in your terminal:--compatibility-date=2023-07-06
See https://developers.cloudflare.com/workers/platform/compatibility-dates/ for more information.
No functions. Shimming...
⛅️ wrangler 3.1.1
------------------
- D1 Bindings are currently in alpha to allow the API to evolve before general availability.
Please report any issues to https://github.com/cloudflare/workers-sdk/issues/new/choose
Note: Run this command with the environment variable NO_D1_WARNING=true to hide this message
For example: `export NO_D1_WARNING=true && wrangler <YOUR COMMAND HERE>`
Your worker has access to the following bindings:
- D1 Databases:
- DB: cozyimg (18898400-dd0c-41ed-a725-9e4ac104ac54)
- DB: local-DB (DB) See https://developers.cloudflare.com/workers/platform/compatibility-dates/ for more information.
No functions. Shimming...
⛅️ wrangler 3.1.1
------------------
- D1 Bindings are currently in alpha to allow the API to evolve before general availability.
Please report any issues to https://github.com/cloudflare/workers-sdk/issues/new/choose
Note: Run this command with the environment variable NO_D1_WARNING=true to hide this message
For example: `export NO_D1_WARNING=true && wrangler <YOUR COMMAND HERE>`
Your worker has access to the following bindings:
- D1 Databases:
- DB: cozyimg (18898400-dd0c-41ed-a725-9e4ac104ac54)
- DB: local-DB (DB)How can i use d1 locally?
refer: