@@ -2,10 +2,7 @@ import { eq } from 'drizzle-orm';
2
2
3
3
import { type IRepository } from '~/libs/interfaces/interfaces.js' ;
4
4
import { type IDatabase } from '~/libs/packages/database/database.js' ;
5
- import {
6
- type DatabaseSchema ,
7
- schema ,
8
- } from '~/libs/packages/database/schema/schema.js' ;
5
+ import { type DatabaseSchema } from '~/libs/packages/database/schema/schema.js' ;
9
6
10
7
import { type UserEntityT } from '../users/users.js' ;
11
8
import { combineFilters } from './libs/helpers/combine-filters.js' ;
@@ -78,11 +75,21 @@ class OrderRepository implements Omit<IRepository, 'find'> {
78
75
} ,
79
76
} )
80
77
. from ( this . ordersSchema )
81
- . innerJoin ( schema . shifts , eq ( this . ordersSchema . shiftId , schema . shifts . id ) )
82
- . innerJoin ( schema . users , eq ( schema . shifts . driverId , schema . users . id ) )
83
78
. innerJoin (
84
- schema . drivers ,
85
- eq ( schema . drivers . userId , schema . shifts . driverId ) ,
79
+ this . shiftsSchema ,
80
+ eq ( this . ordersSchema . shiftId , this . shiftsSchema . id ) ,
81
+ )
82
+ . innerJoin (
83
+ this . usersSchema ,
84
+ eq ( this . shiftsSchema . driverId , this . usersSchema . id ) ,
85
+ )
86
+ . innerJoin (
87
+ this . driversSchema ,
88
+ eq ( this . driversSchema . userId , this . shiftsSchema . driverId ) ,
89
+ )
90
+ . innerJoin (
91
+ this . trucksSchema ,
92
+ eq ( this . trucksSchema . id , this . shiftsSchema . truckId ) ,
86
93
)
87
94
. where ( eq ( this . ordersSchema . id , id ) ) ;
88
95
@@ -125,11 +132,21 @@ class OrderRepository implements Omit<IRepository, 'find'> {
125
132
} ,
126
133
} )
127
134
. from ( this . ordersSchema )
128
- . innerJoin ( schema . shifts , eq ( this . ordersSchema . shiftId , schema . shifts . id ) )
129
- . innerJoin ( schema . users , eq ( schema . shifts . driverId , schema . users . id ) )
130
135
. innerJoin (
131
- schema . drivers ,
132
- eq ( schema . drivers . userId , schema . shifts . driverId ) ,
136
+ this . shiftsSchema ,
137
+ eq ( this . ordersSchema . shiftId , this . shiftsSchema . id ) ,
138
+ )
139
+ . innerJoin (
140
+ this . usersSchema ,
141
+ eq ( this . shiftsSchema . driverId , this . usersSchema . id ) ,
142
+ )
143
+ . innerJoin (
144
+ this . driversSchema ,
145
+ eq ( this . driversSchema . userId , this . shiftsSchema . driverId ) ,
146
+ )
147
+ . innerJoin (
148
+ this . trucksSchema ,
149
+ eq ( this . trucksSchema . id , this . shiftsSchema . truckId ) ,
133
150
)
134
151
. where (
135
152
combineFilters < DatabaseSchema [ 'orders' ] > ( this . ordersSchema , search ) ,
0 commit comments