Help needed: How do i seed my local KV store?
I could find no documentation on this (wtf Cloudfare)
The official docs on KV (https://developers.cloudflare.com/kv/get-started/) were no help:
But this is wrong:
This post:
https://discord.com/channels/595317990191398933/779390076219686943/1151865479556767804
suggested that
My app works in production just fine. This is Remix app by the way How do I seed my KV DB? Any help would be appreciated!
--persist-to=.wrangler/state
would replicate what's in production locally but that's not the case.
Also I tried running:
an this creatd a new sqlite db and added an entry and added an entry to 177ed01a21109c36f2c8627b05dd953e17084c7d07502c2ba22320
5c6b30c8c4.sqlite
that looks like this:
And of course my loader function is not reading this at all.My app works in production just fine. This is Remix app by the way How do I seed my KV DB? Any help would be appreciated!
Get started · Cloudflare Workers KV
Workers KV provides low-latency, high-throughput global storage to your Cloudflare Workers applications. Workers KV is ideal for storing user …
6 Replies
This would be better fit in #pages-help
wrangler devwrangler dev is for Workers and supports --remote
wrangler pages devis for Pages and only supports local mode (I sent my msg on accident lol, I'll add more below, one sec)
suggested that --persist-to=.wrangler/state would replicate what's in production locally but that's not the case.Persist to just specifies the directory to save local data at. It won't pull anything down. He just wanted multiple local workers to share the same data
OK thank you!
I did run
pages dev --local
and tried adding an entry using
but it just adds a blob entry to _mf_entries
and my app cannot read it.
This has been a terrible DX so far
Oh and I'm running my app like so:
They're working on convergence, making Pages/Workers into one product, but that's far into the future. Right now it is def a bit confusing, running pages dev --local shouldn't do anything. Pages dev only supports local mode.
The preview kv would only be used for running workers with --remote, i.e there's
--local (default and only option for Pages), which uses Miniflare/workerd simulated resources
--remote which uses preview IDs and such
actual production deployment which uses the real IDs
They sure don't present it this way. This blog post from 21/12 presents it as ready for prime time https://blog.cloudflare.com/remix-on-cloudflare-pages
I really don't want to have to deploy just to test my app, and adding a k/v entry with wrangler locally should not be creating blobs my app can't read. It's supposed to be JSON data. Am I missing something/ doing it wrong?
The Cloudflare Blog
Supporting Remix with full stack Cloudflare Pages
Cloudflare Pages now natively supports full stack Remix applications.
Doesn't mean it's not ready, just saying local dev and the difference docs/etc is a bit rough with Pages
do you have a wrangler.toml created in your project?
I believe to write to the same one as it uses, you'd want
the namespace-id is what pages-dev uses, you can see in your original command it was storing it under the actual live id
Wow, ok that actually worked. THANK YOU! I now have 3 sqllite dbs in my state dir but I'm able to use it in my route's loader function