Showing
2 changed files
with
19 additions
and
3 deletions
| ... | @@ -3,8 +3,24 @@ import { prisma } from "../../../utils"; | ... | @@ -3,8 +3,24 @@ import { prisma } from "../../../utils"; |
| 3 | export default { | 3 | export default { |
| 4 | Query: { | 4 | Query: { |
| 5 | searchUser: async (_, args) => { | 5 | searchUser: async (_, args) => { |
| 6 | - const { name } = args; | 6 | + const { term } = args; |
| 7 | - const user = await prisma.user.findOne({}); | 7 | + try { |
| 8 | + return prisma.user.findMany({ | ||
| 9 | + where: { | ||
| 10 | + OR: [ | ||
| 11 | + { | ||
| 12 | + name_contains: term, | ||
| 13 | + }, | ||
| 14 | + { | ||
| 15 | + email_contains: term, | ||
| 16 | + }, | ||
| 17 | + ], | ||
| 18 | + }, | ||
| 19 | + }); | ||
| 20 | + } catch (error) { | ||
| 21 | + console.log(error); | ||
| 22 | + } | ||
| 23 | + return null; | ||
| 8 | }, | 24 | }, |
| 9 | }, | 25 | }, |
| 10 | }; | 26 | }; | ... | ... |
-
Please register or login to post a comment