How to type results that includes relations ?

I have two tables: collections and products. Collection has many products.
const results = await db.query.collections.findMany({
with: {
products: {
columns: {
title: true,
slug: true,
images: true,
},
},
},
});
const results = await db.query.collections.findMany({
with: {
products: {
columns: {
title: true,
slug: true,
images: true,
},
},
},
});
I make an api request that gets the response from server. How can I add typing to fetch api response ?
2 Replies
mcgrealife
mcgrealife2y ago
if you invoke findMany() inside a function, you can infer the ReturnType of the function https://discord.com/channels/1043890932593987624/1112458428070236229/1112519441561956352
Shubham-Sinha
Shubham-SinhaOP2y ago
Thanks a lot @mcgrealife
Want results from more Discord servers?
Add your server