File tree Expand file tree Collapse file tree 2 files changed +31
-11
lines changed Expand file tree Collapse file tree 2 files changed +31
-11
lines changed Original file line number Diff line number Diff line change @@ -23,7 +23,7 @@ export default {
23
23
. object ( {
24
24
cursor : z . string ( ) . cuid ( ) . optional ( ) ,
25
25
limit : z . number ( ) . min ( 1 ) . max ( 100 ) . default ( 20 ) ,
26
- searchTerm : z . string ( ) . optional ( ) ,
26
+ searchTerm : z . string ( ) . trim ( ) . optional ( ) . default ( '' ) ,
27
27
} )
28
28
. default ( { } )
29
29
)
@@ -38,10 +38,20 @@ export default {
38
38
context . logger . info ( 'Getting books from database' ) ;
39
39
40
40
const where = {
41
- title : {
42
- contains : input . searchTerm ,
43
- mode : 'insensitive' ,
44
- } ,
41
+ OR : [
42
+ {
43
+ title : {
44
+ contains : input . searchTerm ,
45
+ mode : 'insensitive' ,
46
+ } ,
47
+ } ,
48
+ {
49
+ author : {
50
+ contains : input . searchTerm ,
51
+ mode : 'insensitive' ,
52
+ } ,
53
+ } ,
54
+ ] ,
45
55
} satisfies Prisma . BookWhereInput ;
46
56
47
57
const [ total , items ] = await context . db . $transaction ( [
Original file line number Diff line number Diff line change @@ -7,7 +7,7 @@ import { auth } from '@/server/auth';
7
7
import { protectedProcedure } from '@/server/orpc' ;
8
8
import { getHeaders } from '@/server/utils' ;
9
9
10
- const tags = [ 'user ' ] ;
10
+ const tags = [ 'users ' ] ;
11
11
12
12
export default {
13
13
getAll : protectedProcedure ( {
@@ -25,7 +25,7 @@ export default {
25
25
. object ( {
26
26
cursor : z . string ( ) . optional ( ) ,
27
27
limit : z . number ( ) . min ( 1 ) . max ( 100 ) . default ( 20 ) ,
28
- searchTerm : z . string ( ) . optional ( ) ,
28
+ searchTerm : z . string ( ) . trim ( ) . optional ( ) . default ( '' ) ,
29
29
} )
30
30
. default ( { } )
31
31
)
@@ -38,10 +38,20 @@ export default {
38
38
)
39
39
. handler ( async ( { context, input } ) => {
40
40
const where = {
41
- name : {
42
- contains : input . searchTerm ,
43
- mode : 'insensitive' ,
44
- } ,
41
+ OR : [
42
+ {
43
+ name : {
44
+ contains : input . searchTerm ,
45
+ mode : 'insensitive' ,
46
+ } ,
47
+ } ,
48
+ {
49
+ email : {
50
+ contains : input . searchTerm ,
51
+ mode : 'insensitive' ,
52
+ } ,
53
+ } ,
54
+ ] ,
45
55
} satisfies Prisma . UserWhereInput ;
46
56
47
57
context . logger . info ( 'Getting users from database' ) ;
You can’t perform that action at this time.
0 commit comments