Hi; trying to do some performance optimizations. R...
# orm-help
d
Hi; trying to do some performance optimizations. Right now I return a giant session object for every lookup for convenience's sake. Information that's not included in that object is queried afterwards, in sequential db hits. To make things a little bit more performant, I'm building a type safe function that just pulls the required information to verify the users' cookies _and also whatever select the caller adds_:
Copy code
function resolveSession(cookies: Cookies, select: Prisma.SessionSelect) {
     const session = await prisma.findUnique(where {...}, select: merge(select, {id: xxx, token: yyy, ...}), 
     ...verify session integrity
     return session
}
In fact, I can't even seem to figure out how to write this select in two layers of functions... The first types out ok, but the second...
r
@Dean Valentine 👋 You can’t merge extra fields directly inside
findUnique
. You need to do it after you fetch the response so you’ll get better the correct types in that case based on what you have defined for the session..