how do I access the type of a specific model? E.g....
# orm-help
r
how do I access the type of a specific model? E.g. I am getting a user collection passed via props (nextjs), how do I specify the type of it?
r
@Robin 👋 Could you share an example? I didn’t quite get your question.
r
For example I have this code:
Copy code
export const getServerSideProps: GetServerSideProps = async (context) => {
  const users = await prisma.user.findMany({});

  const singleUser: ??? = users[0]

  return { props: { users } };
};

export default function Index({ users }: { users: ???? }) {
  return (
    <Layout>

      <div className="space-y-3">
        <div className="text-xl">Leaderboard</div>
        <div>
          <ul>
            {users.map((user: ?????, i) => {
              return (
                <li key={user.id}>{user.name}</li>
              );
            })}
          </ul>
        </div>
      </div>

    </Layout>
  );
}
You see a few places where I put some '????' where I dont know how to specify the model
r
You can directly import the user type:
Copy code
import { User } from '@prisma/client'
r
awesome, thanks a lot!
👍 1