nehalist
Explore posts from serversDTDrizzle Team
•Created by nehalist on 7/17/2024 in #help
Types in Next.js Client components
I've got a schema (
schema.ts
) which defines my tables, a file for type declarations (types.ts
) with things like export type Product = typeof products.$inferSelect;
How am I supposed to use these types in client components? Since the types.ts
imports from schema.ts
we're no longer in client-only land and I get errors like Cannot resolve module 'fs'
and similar.6 replies
DTDrizzle Team
•Created by nehalist on 7/17/2024 in #help
Enum array column
Hey there,
anyone got an idea why doesn't this work:
the error:
PostgresError: type "productmodule[]" does not existbut... why?
39 replies
DTDrizzle Team
•Created by nehalist on 1/23/2024 in #help
Is there an easy way for "member of"?
I do have a user and group table, and would like to get all groups where a user is member of. I could easily do that with joins, but I do know that some db frameworks (like doctrine) offer a "member of" helper. Is there something alike (that I'm too dumb to find in the docs)?
3 replies
Implementing a "Prisma model converter middleware"
Bit of a fancy name, but if you've ever worked with Symfonys param converters (especially the DoctrineParamConverter) you get the idea. It's basically just automatically converting input to models.
Currently trying to implement this, but can't find a way for proper types. Implementation so far:
Unfortunately I can't come up with a solution to knowing the types here. Anyone got some ideas 🙂 ?
2 replies
Is there a way to transform data server-side only?
I'd like to implement something like Symfonys ParamConverter that converts certain params, but server-side only, so that I can use Prisma and alike. Couldn't figure out how to use data transformers for this use case
3 replies
Has anyone ever used tRPC (with SSR) and i18n?
No matter the lib (next-intl, next-i18n, next-translate), I simply stumble from one problem to another - most of them simply solved by disabling SSR. Unfortunately, I need SSR and i18n. I know the GitHub issue that the problem here is on next.js, but anyone ever solved this? Hard to believe no one has ever used tRPC with i18n
35 replies
Request context from getServerSideProps
The docs of tRPC context https://trpc.io/docs/v10/context
But how to use this function from
getServerSideProps
(in order to use SSG helpers)?2 replies
tRPC without SSR
When using tRPC with ssr it uses
getInitialProps
, which has kinda of a cool effect in terms how a page is rendered, since it's rendered server-side on initial requests and client-side on route transitions.
Unfortunately, enabling ssr means that you can no longer use getServerSideProps
(which I know is only fixable by next.js and not tRPC). But how to replicate the getInitialProps
behaviour then?
Let's say I'm building a blog; due to SEO it's basically necessary to render my posts server-side. But when navigating through the site loading posts on the fly would be totally fine. How to do that without ssr
?16 replies
Load data client-side via react-query while using tRPC with SSR
Is there any way to load data client-side when using tRPC? I want my page to be rendered and load data dynamically, since this data is not SEO-relevant. As far as I'm understanding as soon as I turn on SSR in tRPC queries must be done before the page is rendered.
11 replies
SSR and loading indicators - I don't get it
Guess I'm missing something here, but unfortunately I'm having a hard time with the docs: in https://trpc.io/docs/v10/nextjs the example
utils/trcp.ts
sets ssr: true
, but the pages/index.tsx
example uses
Since SSR would prevent the page from being rendered until the queries are done, how would this loading indicator ever been shown?1 replies