icanflyit
Explore posts from serversDTDrizzle Team
•Created by icanflyit on 8/22/2024 in #help
Drizzle client nested schemas
Is there a way to nest schemas within the Drizzle Queries? I have my schemas multiple files in sub directories, and I export them in groups.
This helps with organization and works with the select and insert, but to use queries I have to spread my schema when passing it to drizzle.
Ideally, I'd be able to query users like vs.
Is this possible in drizzle?
1 replies
DTDrizzle Team
•Created by icanflyit on 8/19/2024 in #help
drizzle-typebox loses typechecking when used from another package
I'm setting up a project with a monorepo (available at https://github.com/trilliumlab/trail-eyes-monorepo/blob/3459d8014508365d256db5cc8b088e880f8b29f6/)
I have a separate package for the database that can be shared with all my apps. I use typebox throughout the project, so the
database
package uses drizzle-typebox and createInsertSchema
to generate my typebox schemas.
For some reason, it seems I lose typing from any schemas created with drizzle-typebox
when I try to use them outside of the database
package. This doesn't seem to happen with typebox schemas I create myself.
What I mean by this is I have a file in my database that I setup to have a function that takes a drizzle-typebox generated schema, a function with a regular typebox schema, and a function with an object with a regular typescript definition (https://github.com/trilliumlab/trail-eyes-monorepo/blob/3459d8014508365d256db5cc8b088e880f8b29f6/packages/database/src/database.ts). I then try passing an empty object to these 3 functions and the inference works as it should.
I then have a file in another package in my monorepo (https://github.com/trilliumlab/trail-eyes-monorepo/blob/3459d8014508365d256db5cc8b088e880f8b29f6/apps/scripts/src/db/import-routes.ts) This just calls the same 3 functions from above, but for some reason the first function shows no typescript error when I pass it {}
, and other 2 behave as they should.
I'm sure it's just something with my typescript configuration, but it's weird to me that it only happens with drizzle-typebox and not regular typebox schemas. If anyone had any input that would be greatly appreciated :)4 replies
How to do client side redirects
Quick client vs SSR question: What is the recommended way to do a redirect from the client side? My understanding is
throw redirect()
is only available from an SSR context.
Also, if I wanted to redirect regardless of whether I was client of server side, would "use_server"
along with throw redirect()
be appropriate there. If not what would the recommended way to do this be.13 replies
SSR Cookies
Hi all,
I'm new to SSR and don't fully understand in the solidstart basic example which components are being rendered server side / client side.
I'm using tanstack solid-query and for testing I have a button that on press calls a /click route on my server and adds a row to the database consisting of:
- a deviceId cookie
- the current time
I then have a /clicks routes that gets the number of clicks for each deviceId (and i use createQuery to use it in solid)
Every time the routes /click and /clicks are called, the server checks if deviceId cookie exists and generates a new deviceId if not.
This works great if I have a button or something that forces the query to be done client side, since all the client side cookies are passed, however if I try to get the value of that query on the official page load, the cookies aren't passed and so the initial state always begins at 0
My question is is there a way to pass the client cookies when making server side requests?
43 replies