Order
Explore posts from serversDoes blazor webassembly not contain a "backend" server?
So I'm a complete beginner when it comes to C# and dotnet development. Whenever I learn a new framework I always make the same app - a simple chat app, as it both helps me understand how to interface with a database, with real-time communication (websockets) and with dynamic client-side rendering. However I started following a tutorial about using clientR and I soon realized that my blazor project doesn't have a server!? What type of project should I create to have both a classic backend and a frontend, in my understanding the blazor wasm template is similar to "vite" in the javascript world (frontend only) so I can't really host my websocket server. I'm also using VSCode instead of VS2022 which is not helping as I have to use the CLI to create the project and I don't know what command I should use for a full stack type of project.
32 replies
PPrisma
•Created by Order on 5/16/2024 in #help-and-questions
I want to find a user with either email or username but I'm getting a typescript error
I'm setting up nextauth in nextjs with prisma and postgres and I want the user to be able to interchangably log in with either email or password. So I set this up:
async authorize(credentials) {
const user = await prisma.user.findUnique({
where: {
OR: [
{
email: credentials?.username,
},
{
username: credentials?.username,
},
],
},
});
However I'm getting a type error on my where Type '{ OR: ({ email: string | undefined; } | { username: string | undefined; })[]; }' is not assignable to type 'UserWhereUniqueInput'.
Type '{ OR: ({ email: string | undefined; } | { username: string | undefined; })[]; }' is not assignable to type '{ id: string; email: string; username: string; } & { id?: string | undefined; username?: string | undefined; email?: string | undefined; AND?: UserWhereInput | UserWhereInput[] | undefined; ... 10 more ...; sessions?: SessionListRelationFilter | undefined; }'.
Type '{ OR: ({ email: string | undefined; } | { username: string | undefined; })[]; }' is missing the following properties from type '{ id: string; email: string; username: string; }': id, email, usernamets(2322)
index.d.ts(3896, 5): The expected type comes from property 'where' which is declared here on type '{ select?: UserSelect<DefaultArgs> | null | undefined; include?: UserInclude<DefaultArgs> | null | undefined; where: UserWhereUniqueInput; }'
(property) where: Prisma.UserWhereUniqueInput
.
I'm pretty sure I'm doing something wrong but I don't know what. Both my username and email fields in my user model are marked as unique.3 replies