Passage and Planetscale DB - how to query data with user authed Id? to get user posts?
Unanswered
Asiatic Lion posted this in #help-forum
Asiatic LionOP
Once the user logs in with passage, we want that id so that it shows their custom feed
But currently, we can only get the user_id through client side and the query things is server side
But running it we get this error:
How can we query db with user authenticated ? We're using Passage from https://docs.passage.id/frontend/passage.js
But currently, we can only get the user_id through client side and the query things is server side
import { db } from "@/lib/db";
import PostFeed from "../PostFeed";
// import { notFound } from "next/navigation";
import { getCurrentUserInfo } from "@/actions/getCurrentUserInfo";
const CustomFeed = async ({ ...userInfo }) => {
if (!userInfo.id)
return (
<>
<h1>No id found</h1>
</>
);
const posts = await db.post.findMany({
where: {
authorId: userInfo.id, // Corrected assignment syntax
},
orderBy: {
createdAt: "desc",
},
});
console.log(posts);
return <PostFeed initialPosts={posts} />;
};
export default CustomFeed;But running it we get this error:
You're importing a component that needs server-only. That only works in a Server Component but one of its parents is marked with "use client", so it's a Client Component.
,-[D:\dev\fork-passage_fullstack\src\lib\db.ts:1:1]
1 | import { PrismaClient } from '@prisma/client'
2 | import "server-only"
: ^^^^^^^^^^^^^^^^^^^^How can we query db with user authenticated ? We're using Passage from https://docs.passage.id/frontend/passage.js