Hi guys - When a user signs up for the first time ...
# orm-help
v
Hi guys - When a user signs up for the first time i dont have any information about them in my User table. So when they login for the first time my query looks at the user table for their authId and returns a null. Prisma throws a null error in the logs. how do i prevent this? How to handle a null return in a Prisma findUnique? my getter is below -
Copy code
export const getUser = (id) => {
    return prisma.User.findUnique({
        where: { authId: id },
    });
};
1
j
Do you mean you want to handle null value of throw error back to the client?
Copy code
async getById(id: string) {
    try {
      const userInfo = await this.prismaService.user.findUnique({
        where: { id },
      });
      if (!userInfo) {
        throw new NotFoundError('User');
      }
      return userInfo;
    } catch (e) {
      throw new ServiceError(this.serviceName, e);
    }
  }
1
🤘 1
v
thank you so much @Jarupong. I just followed you on twitter!
j
Followed back
And my solution will help you
Hopefully
Sorry for making you confusing, i have personal account and company account
v
thank you so much. I will give this a try!!!
That worked! thank you
j
Happy to help 😃