cosbgn
Explore posts from serversDTDrizzle Team
•Created by cosbgn on 9/10/2024 in #help
Any way to use D1 remote DB (production one) while locally?
On wrangler is enough to add --remote but not sure how it works on drizzle
1 replies
DTDrizzle Team
•Created by cosbgn on 9/4/2024 in #help
generated columns reference another table
I have a table called users and another called teams. I would like to have users.plan be generated from teams.id === user.team_id and from that team get teams.plan. So pretty much user.plan is generated from the right team plan.
Is this possible?
2 replies
CDCloudflare Developers
•Created by cosbgn on 8/16/2024 in #pages-help
Is there any way to access a pages deployment without passing first from the cloudflare CDN?
My issue is that the cloudflare CDN has a 100 second timeout and I need a long running backend task. Pages doesn't support crons or queues, so I can rely on an external cron tool, but I would need to connect directly to the worker skipping the CDN
4 replies
CDCloudflare Developers
•Created by cosbgn on 8/5/2024 in #pages-help
Is there any workarount to get Cron Triggers or bckground tasks to work on pages?
I'm very limited by pages for their 100second timeout and absence of queues, crons, etc.
How does everyone deals with longer tasks on pages?
2 replies
DTDrizzle Team
•Created by cosbgn on 7/7/2024 in #help
ERROR [unhandledRejection] connect ECONNREFUSED 127.0.0.1:60589
I use a drizzle-http-sqlite proxy to connect to my remote D1. After a while it hungs with this error. My issue is that I'm not connecting to a localhost so I have no idea why it happens. This is my proxy:
1 replies
DTDrizzle Team
•Created by cosbgn on 7/5/2024 in #help
D1_ERROR: near "in": syntax error at offset 153
I can't seem to use
inArray
with d1:
With
Any suggestions?2 replies
Is there an easy way to get `event`?
I use drizzle and cloudflare so I have an util like this one:
My issue is that I need always event and it's annoying to pass it around betwen functions. I know there is
useEvent()
but it requires an experimental asyncContext
which is not available on cloudflare.
How is everyone solving this?8 replies
get `event` in `/utils/db.js` - Can I be done?
I would like to do something like this:
So then in any route I can do
db.select()
- However useRequestEvent()
is not defined somehow?
I know I can simply pass const db = useDb(event)
on top of each route, I just would like to avoid passing event on every route and hopefully get better types. Should this instead be a plugin? What's the best practice here?2 replies
DTDrizzle Team
•Created by cosbgn on 4/18/2024 in #help
Cannot read properties of null (reading 'dialect')
await migrate(db, { migrationsFolder: "server/db/migrations" })
is failing. I'm using d1. What could be the issue?1 replies
CDCloudflare Developers
•Created by cosbgn on 4/10/2024 in #pages-help
Mailchannels: sender is not authorized
I'm getting:
I have a TXT record with:
name:
value:
_mailchannels
value:
=mc1 cfid=my-site-v3.pages.dev
(copied as is from error message)
---
Do I need to just wait for DNS to catch up, or am I missing something?6 replies
DTDrizzle Team
•Created by cosbgn on 4/3/2024 in #help
How do you deal with migrations? on postbuild?
So, usually while developing locally, whenever I change my schema I run:
This first generates the migrations and then applies them to my local db.
Once I deploy in my package.json postbuild script I have:
So if my build runs without issues, it will apply the migrations to my production DB.
Is this correct?
1 replies
DTDrizzle Team
•Created by cosbgn on 3/13/2024 in #help
How do I mark "migration as applied" after using "push"?
I've been using push for a while, now my migrations don't work anymore because:
10 replies
DTDrizzle Team
•Created by cosbgn on 3/13/2024 in #help
returning with onConflictDoUpdate - How do I know if it was updated?
If I do:
Without returning I know if the row was added or edited, but I don't get the
ID
- With returning, I get the id
but I don't know if it was created or just updated.
Any way to know both?1 replies
DTDrizzle Team
•Created by cosbgn on 2/27/2024 in #help
Do I need to cache `createClient`?
I use turso on the edge (CF Workers). I see a lot of implementations do something like this:
Is that the right approach? Or can I simply do:
Like can I call
createClient()
hundreds of times without issues or I should actually cache it?1 replies
DTDrizzle Team
•Created by cosbgn on 1/25/2024 in #help
Why do I need to duplicate names in my schema?
For example:
Why do I need
name
twice? I can easily forget to update one or another creating a mess, like name: text('old_name')
Any way to avoid it?2 replies