mmurto
mmurto
Explore posts from servers
TTCTheo's Typesafe Cult
Created by mmurto on 6/13/2023 in #questions
Split tRPC to two endpoints on lambda and edge with Next
Is it possible/are there some examples of splitting the tRPC endpoint into two endpoints? My initial experiments a while back encountered some problems with trying to use nested withTRPCs. I'd like to have most of my routers on edge, but some don't work there, so need to leave them to lambdas.
2 replies
TTCTheo's Typesafe Cult
Created by mmurto on 4/29/2023 in #questions
tRPC with part on NextJS Lambdas and part on Edge
How should I go with splitting tRPC to have some functions execute on serverless/lambdas and some on edge functions? I tried creating two separate routers with nested withTRPCs, but it didn't work.
2 replies
DTDrizzle Team
Created by mmurto on 4/17/2023 in #help
Raw SQL / Postgres stored generated column in schema
Is it possibile to add raw sql, or more specifically stored generated columns to the schema? Trying to store a length field of a text column.
1 replies
DTDrizzle Team
Created by mmurto on 4/12/2023 in #help
How to count joined table?
I'm trying to count rows returned by join for a query, basically the same as this: https://dba.stackexchange.com/questions/110850/count-rows-with-inner-joined-tables How to convert this to Drizzle? Any documentation I've missed regarding this kind of things?
SELECT t1.team_name,
IFNULL(t2.num_players, 0) AS strength,
t1.team_timestamp
FROM team t1
LEFT OUTER JOIN
(SELECT team_id, COUNT(team_id) AS num_players
FROM player
GROUP BY team_id
) t2
ON t1.team_id = t2.team_id
-- GROUP BY t1.team_id, t1.team_name, t1.season_id -- **NOTE** - see discussion below
ORDER BY strength DESC, team_name ASC;
SELECT t1.team_name,
IFNULL(t2.num_players, 0) AS strength,
t1.team_timestamp
FROM team t1
LEFT OUTER JOIN
(SELECT team_id, COUNT(team_id) AS num_players
FROM player
GROUP BY team_id
) t2
ON t1.team_id = t2.team_id
-- GROUP BY t1.team_id, t1.team_name, t1.season_id -- **NOTE** - see discussion below
ORDER BY strength DESC, team_name ASC;
2 replies
TTCTheo's Typesafe Cult
Created by mmurto on 4/11/2023 in #questions
Handle trailing slash in NextJS API routes?
I'm trying to create an integration to Fibery through NextJS's API routes, but Fibery's integration engine seems to send one request to api/integration/ (trailing slash) and some to api/integration/schema etc, which I can't make work with the API dir. 😄 Any way to force index.ts in API route to handle both the trailing slash and without?
3 replies
DTDrizzle Team
Created by mmurto on 4/9/2023 in #help
How to filter length in where for postgres?
I have a text field, which I want to select only if it's length is higher than 50. How should I do that? So I basically need to transfer where length(item.content) >= 50 to Drizzle.
4 replies
TTCTheo's Typesafe Cult
Created by mmurto on 3/24/2023 in #questions
`import` and `require` in the same file?
I'm trying to use https://github.com/luin/ioredis and https://github.com/rse/tika-server/tree/master in the same project. When trying to build a Docker image out of the project, I can't seem to get it working as ioredis needs to be imported and tika-server required. What is that interaction about? Any clues how to get this working or what I may have set up wrong?
2 replies
TTCTheo's Typesafe Cult
Created by mmurto on 3/19/2023 in #questions
`onSuccess` is typed correctly as `data: ReturnItem` for one mutation but as `data: any` for another
onSuccess is typed correctly as data: ReturnItem for one mutation but as data: any for another, any ideas why? I see no apparent reason.
2 replies
DTDrizzle Team
Created by mmurto on 3/17/2023 in #help
Argument of type 'SQL<unknown>' is not assignable to parameter
I have the following:
const projects = await db
.select()
.from(project)
.where(eq(project.ownerId, userId));
const projects = await db
.select()
.from(project)
.where(eq(project.ownerId, userId));
and the eq() gives an error like:
Argument of type 'SQL<unknown>' is not assignable to parameter of type 'SQL<unknown> | ((aliases: { id: MySqlColumn<{ data: string; driverParam: string | number; notNull: true; hasDefault: true; tableName: "Project"; }>; name: MySqlColumn<{ data: string; driverParam: string | number; hasDefault: false; notNull: true; tableName: "Project"; }>; description: MySqlColumn<...>; createdAt: My...'.

Type 'Name' is not assignable to type 'Chunk'.
Property 'encoder' is missing in type 'Name' but required in type 'Param<unknown, unknown>'.ts(2345)
index.d.ts(80, 14): 'encoder' is declared here.
Argument of type 'SQL<unknown>' is not assignable to parameter of type 'SQL<unknown> | ((aliases: { id: MySqlColumn<{ data: string; driverParam: string | number; notNull: true; hasDefault: true; tableName: "Project"; }>; name: MySqlColumn<{ data: string; driverParam: string | number; hasDefault: false; notNull: true; tableName: "Project"; }>; description: MySqlColumn<...>; createdAt: My...'.

Type 'Name' is not assignable to type 'Chunk'.
Property 'encoder' is missing in type 'Name' but required in type 'Param<unknown, unknown>'.ts(2345)
index.d.ts(80, 14): 'encoder' is declared here.
What could be the problem?
10 replies
TTCTheo's Typesafe Cult
Created by mmurto on 3/13/2023 in #questions
How to get context type of protectedProcedure?
I want to keep my logic outside of the routes by using functions and just calling them in the router. Is there a way to get the type of the context with the procedures applied, i.e., I want to get types ProtectedProcedureContext and PublicProcedureContext to use as input types for a function. How to?
5 replies
TTCTheo's Typesafe Cult
Created by mmurto on 2/20/2023 in #questions
How to redirect from login page with trpc's SSR enabled?
Any simple solutions for redirecting unauthenticated users to /login and authenticated users from /login to / with trpc's SSR enabled, i.e., without the use of getServerSideProps?
3 replies