Myrseth
Myrseth
Explore posts from servers
TTCTheo's Typesafe Cult
Created by Myrseth on 7/15/2023 in #questions
React Cache Function
Hey, according to Next.js docs, you can cache db queries and similar with the cache function from React, however I do get an error when deploying to Vercel. https://nextjs.org/docs/app/building-your-application/data-fetching/caching#per-request-caching What can be the issue? I can confirm I am using the latest version of next, react and react-dom. The cache function is indeed imported and used from react like described in the docs;
import { db } from '@/drizzle';
import { rolle } from '@/drizzle/schema';
import { eq, placeholder } from 'drizzle-orm';
import { cache } from 'react';

const rolleQuery = db
.select()
.from(rolle)
.where(eq(rolle.individualId, placeholder('individualId')))
.prepare();

export const getRoles = cache(async (individualId: string) => {
const roles = await rolleQuery.execute({ individualId });
if (roles.length === 0) {
return null;
}
return roles;
});
import { db } from '@/drizzle';
import { rolle } from '@/drizzle/schema';
import { eq, placeholder } from 'drizzle-orm';
import { cache } from 'react';

const rolleQuery = db
.select()
.from(rolle)
.where(eq(rolle.individualId, placeholder('individualId')))
.prepare();

export const getRoles = cache(async (individualId: string) => {
const roles = await rolleQuery.execute({ individualId });
if (roles.length === 0) {
return null;
}
return roles;
});
2 replies
DTDrizzle Team
Created by Myrseth on 7/15/2023 in #help
Placeholders in inserting: db.insert().values(placeholder('example'))
Hey, how do I add placeholders inside the values of an insert prepare statement? I get an typeerror when I do so.
5 replies
TTCTheo's Typesafe Cult
Created by Myrseth on 7/15/2023 in #questions
Drizzle search column for string
Very noob question: Hey, I've switched to Drizzle, set up my tables. I've also looked into the filters and operations, but I cannot find any way to search a column for values containing x, e.g. for a search field of usernames. How can I do this in Drizzle? Any answer is greatly appreciated.
8 replies
TTCTheo's Typesafe Cult
Created by Myrseth on 5/29/2023 in #questions
/app dir slower than pages?
Hey, is the /app dir actually slower than the regular pages dir from next 12? If so, is it even a point migrating old next 12 apps to 13.4 with the new app dir? Just saw this yt vid: https://youtu.be/3Q2q2gs0nAI
1 replies
TTCTheo's Typesafe Cult
Created by Myrseth on 5/23/2023 in #questions
Next 13 App Dir, performance benefits
Hello, are there really any performance benefits using server components and the app directory compared to regular SSG from Next 12? Is it worth migrating to the app dir?
11 replies
TTCTheo's Typesafe Cult
Created by Myrseth on 5/16/2023 in #questions
Next.js vs competing frameworks
Hello, is there any point in learing other frameworks than Next.js, such as SvelteKit or Nuxt to advance in the job market? I've been using Next.js for a few years, and I just tried out SvelteKit finding it okay, but is there any point for me in learning any other frameworks than Next.js - other than general learning and expanding horizons? Or would it be more beneficial to just get really good at Next.js and ignore the competition (as long as the next.js marketshare is superior)?
6 replies