bockster6669
bockster6669
Explore posts from servers
PPrisma
Created by bockster6669 on 9/11/2024 in #help-and-questions
Search text with Prisma
hi, thank you, but can you help for this now? I am having strange problem, why when formattedQuery is undefined it doesn't finds any posts, but if I refer directly undefined to search then it finds all posts?
const formattedQuery = formatSearchQuery(searchInputParam);

try {
const posts = await PostRepo.findMany({
where: {
title: {
search: formattedQuery,
},
},
const formattedQuery = formatSearchQuery(searchInputParam);

try {
const posts = await PostRepo.findMany({
where: {
title: {
search: formattedQuery,
},
},
For example* I can use
orderBy: {
createdAt: undefined,
}
orderBy: {
createdAt: undefined,
}
and this will work find, the posts will not be sorted by any mean but I can not use
const variable = undefined
orderBy: {
createdAt: variable ,
}
const variable = undefined
orderBy: {
createdAt: variable ,
}
This will not work! I am getting error:
Error occurred while fetching posts: PrismaClientValidationError:
Invalid `prisma.post.findMany()` invocation:

{
where: {
title: {
search: "undefined"
}
},
include: {
author: true,
tags: true,
comments: {
include: {
author: true
}
}
},
orderBy: {
createdAt: "undefined"
~~~~~~~~~~~
}
}
Error occurred while fetching posts: PrismaClientValidationError:
Invalid `prisma.post.findMany()` invocation:

{
where: {
title: {
search: "undefined"
}
},
include: {
author: true,
tags: true,
comments: {
include: {
author: true
}
}
},
orderBy: {
createdAt: "undefined"
~~~~~~~~~~~
}
}
4 replies
PPrisma
Created by bockster6669 on 9/3/2024 in #help-and-questions
Prisma Types
PostModel.findMany return only Post[] instead of Post[] & Tag: {name: string}
6 replies
PPrisma
Created by bockster6669 on 9/3/2024 in #help-and-questions
Prisma Types
PostFindUniqueResult is the correct type, but PostModel.findMany doesnt return it
6 replies
PPrisma
Created by bockster6669 on 9/3/2024 in #help-and-questions
Prisma Types
same as this one and so on
type PostFindManyResult = Prisma.Result<
typeof db.post,
{
include: {
tags: {
select: {
name: true,
},
},
},
},
'findMany'
>;

const posts:PostFindManyResult = await PostModel.findMany({
include: {
tags: {
select: {
name: true,
},
},
},
});
type PostFindManyResult = Prisma.Result<
typeof db.post,
{
include: {
tags: {
select: {
name: true,
},
},
},
},
'findMany'
>;

const posts:PostFindManyResult = await PostModel.findMany({
include: {
tags: {
select: {
name: true,
},
},
},
});
6 replies
PPrisma
Created by bockster6669 on 8/31/2024 in #help-and-questions
is there a `substring` method in prisma?
yea I know, this doens't fix the bigger network traffic
7 replies
PPrisma
Created by bockster6669 on 8/31/2024 in #help-and-questions
is there a `substring` method in prisma?
I just want to take the first 50 characters of a sentance
7 replies