Changeset 1ebac59 for database/drizzle/schema/relations.ts
- Timestamp:
- 12/20/25 00:55:47 (7 months ago)
- Branches:
- main
- Children:
- b69759d
- Parents:
- c30935a
- File:
-
- 1 edited
-
database/drizzle/schema/relations.ts (modified) (11 diffs)
Legend:
- Unmodified
- Added
- Removed
-
database/drizzle/schema/relations.ts
rc30935a r1ebac59 7 7 memoryTable, 8 8 powerSupplyTable, 9 pcCase Table,9 pcCasesTable, 10 10 caseStorageFormFactorsTable, 11 11 casePsFormFactorsTable, 12 12 caseMoboFormFactorsTable, 13 cooler Table,13 coolersTable, 14 14 coolerCPUSocketsTable, 15 motherboard Table,15 motherboardsTable, 16 16 storageTable, 17 memoryCardTable, 18 opticalDriveTable, 19 soundCardTable, 20 soundCardChannelsTable, 17 memoryCardsTable, 18 opticalDrivesTable, 19 soundCardsTable, 21 20 cablesTable, 22 networkAdapter Table,23 networkCard Table,21 networkAdaptersTable, 22 networkCardsTable, 24 23 25 24 } from "./components"; 26 25 27 26 import { 28 build Table,29 buildComponent Table,30 favoriteBuild Table,31 ratingBuild Table,32 review Table27 buildsTable, 28 buildComponentsTable, 29 favoriteBuildsTable, 30 ratingBuildsTable, 31 reviewsTable 33 32 } from "./builds" 34 33 … … 40 39 41 40 export const usersRelations = relations(usersTable, ({ many, one }) => ({ 42 builds: many(build Table),43 reviews: many(review Table),44 favorites: many(favoriteBuild Table),45 ratings: many(ratingBuild Table),41 builds: many(buildsTable), 42 reviews: many(reviewsTable), 43 favorites: many(favoriteBuildsTable), 44 ratings: many(ratingBuildsTable), 46 45 suggestions: many(suggestionsTable), 47 46 adminProfile: one(adminsTable, { … … 70 69 })); 71 70 72 export const buildRelations = relations(build Table, ({ one, many }) => ({71 export const buildRelations = relations(buildsTable, ({ one, many }) => ({ 73 72 owner: one(usersTable, { 74 fields: [build Table.userId],75 references: [usersTable.id], 76 }), 77 buildComponents: many(buildComponent Table),78 favorites: many(favoriteBuild Table),79 ratings: many(ratingBuild Table),80 reviews: many(review Table),81 })); 82 83 export const buildComponentRelations = relations(buildComponent Table, ({ one }) => ({84 build: one(build Table, {85 fields: [buildComponent Table.buildId],86 references: [build Table.id],87 }), 88 component: one(componentsTable, { 89 fields: [buildComponent Table.componentId],90 references: [componentsTable.id], 91 }), 92 })); 93 94 export const favoriteBuildRelations = relations(favoriteBuild Table, ({ one }) => ({73 fields: [buildsTable.userId], 74 references: [usersTable.id], 75 }), 76 buildComponents: many(buildComponentsTable), 77 favorites: many(favoriteBuildsTable), 78 ratings: many(ratingBuildsTable), 79 reviews: many(reviewsTable), 80 })); 81 82 export const buildComponentRelations = relations(buildComponentsTable, ({ one }) => ({ 83 build: one(buildsTable, { 84 fields: [buildComponentsTable.buildId], 85 references: [buildsTable.id], 86 }), 87 component: one(componentsTable, { 88 fields: [buildComponentsTable.componentId], 89 references: [componentsTable.id], 90 }), 91 })); 92 93 export const favoriteBuildRelations = relations(favoriteBuildsTable, ({ one }) => ({ 95 94 user: one(usersTable, { 96 fields: [favoriteBuild Table.userId],97 references: [usersTable.id], 98 }), 99 build: one(build Table, {100 fields: [favoriteBuild Table.buildId],101 references: [build Table.id],102 }), 103 })); 104 105 export const ratingBuildRelations = relations(ratingBuild Table, ({ one }) => ({95 fields: [favoriteBuildsTable.userId], 96 references: [usersTable.id], 97 }), 98 build: one(buildsTable, { 99 fields: [favoriteBuildsTable.buildId], 100 references: [buildsTable.id], 101 }), 102 })); 103 104 export const ratingBuildRelations = relations(ratingBuildsTable, ({ one }) => ({ 106 105 user: one(usersTable, { 107 fields: [ratingBuild Table.userId],108 references: [usersTable.id], 109 }), 110 build: one(build Table, {111 fields: [ratingBuild Table.buildId],112 references: [build Table.id],113 }), 114 })); 115 116 export const reviewRelations = relations(review Table, ({ one }) => ({106 fields: [ratingBuildsTable.userId], 107 references: [usersTable.id], 108 }), 109 build: one(buildsTable, { 110 fields: [ratingBuildsTable.buildId], 111 references: [buildsTable.id], 112 }), 113 })); 114 115 export const reviewRelations = relations(reviewsTable, ({ one }) => ({ 117 116 author: one(usersTable, { 118 fields: [review Table.userId],119 references: [usersTable.id], 120 }), 121 build: one(build Table, {122 fields: [review Table.buildId],123 references: [build Table.id],117 fields: [reviewsTable.userId], 118 references: [usersTable.id], 119 }), 120 build: one(buildsTable, { 121 fields: [reviewsTable.buildId], 122 references: [buildsTable.id], 124 123 }), 125 124 })); 126 125 127 126 export const componentsRelations = relations(componentsTable, ({ many, one }) => ({ 128 buildComponents: many(buildComponent Table),127 buildComponents: many(buildComponentsTable), 129 128 130 129 cpu: one(CPUTable, { … … 144 143 references: [powerSupplyTable.componentId] 145 144 }), 146 pcCase: one(pcCase Table, {147 fields: [componentsTable.id], 148 references: [pcCase Table.componentId]149 }), 150 cooler: one(cooler Table, {151 fields: [componentsTable.id], 152 references: [cooler Table.componentId]153 }), 154 motherboard: one(motherboard Table, {155 fields: [componentsTable.id], 156 references: [motherboard Table.componentId]145 pcCase: one(pcCasesTable, { 146 fields: [componentsTable.id], 147 references: [pcCasesTable.componentId] 148 }), 149 cooler: one(coolersTable, { 150 fields: [componentsTable.id], 151 references: [coolersTable.componentId] 152 }), 153 motherboard: one(motherboardsTable, { 154 fields: [componentsTable.id], 155 references: [motherboardsTable.componentId] 157 156 }), 158 157 storage: one(storageTable, { … … 160 159 references: [storageTable.componentId] 161 160 }), 162 memoryCard: one(memoryCard Table, {163 fields: [componentsTable.id], 164 references: [memoryCard Table.componentId]165 }), 166 opticalDrive: one(opticalDrive Table, {167 fields: [componentsTable.id], 168 references: [opticalDrive Table.componentId]169 }), 170 soundCard: one(soundCard Table, {171 fields: [componentsTable.id], 172 references: [soundCard Table.componentId]161 memoryCard: one(memoryCardsTable, { 162 fields: [componentsTable.id], 163 references: [memoryCardsTable.componentId] 164 }), 165 opticalDrive: one(opticalDrivesTable, { 166 fields: [componentsTable.id], 167 references: [opticalDrivesTable.componentId] 168 }), 169 soundCard: one(soundCardsTable, { 170 fields: [componentsTable.id], 171 references: [soundCardsTable.componentId] 173 172 }), 174 173 cables: one(cablesTable, { … … 176 175 references: [cablesTable.componentId] 177 176 }), 178 networkAdapter: one(networkAdapter Table, {179 fields: [componentsTable.id], 180 references: [networkAdapter Table.componentId]181 }), 182 networkCard: one(networkCard Table, {183 fields: [componentsTable.id], 184 references: [networkCard Table.componentId]177 networkAdapter: one(networkAdaptersTable, { 178 fields: [componentsTable.id], 179 references: [networkAdaptersTable.componentId] 180 }), 181 networkCard: one(networkCardsTable, { 182 fields: [componentsTable.id], 183 references: [networkCardsTable.componentId] 185 184 }), 186 185 })); … … 214 213 })); 215 214 216 export const motherboardRelations = relations(motherboard Table, ({ one }) => ({217 component: one(componentsTable, { 218 fields: [motherboard Table.componentId],215 export const motherboardRelations = relations(motherboardsTable, ({ one }) => ({ 216 component: one(componentsTable, { 217 fields: [motherboardsTable.componentId], 219 218 references: [componentsTable.id], 220 219 }), … … 228 227 })); 229 228 230 export const memoryCardRelations = relations(memoryCard Table, ({ one }) => ({231 component: one(componentsTable, { 232 fields: [memoryCard Table.componentId],233 references: [componentsTable.id], 234 }), 235 })); 236 237 export const opticalDriveRelations = relations(opticalDrive Table, ({ one }) => ({238 component: one(componentsTable, { 239 fields: [opticalDrive Table.componentId],229 export const memoryCardRelations = relations(memoryCardsTable, ({ one }) => ({ 230 component: one(componentsTable, { 231 fields: [memoryCardsTable.componentId], 232 references: [componentsTable.id], 233 }), 234 })); 235 236 export const opticalDriveRelations = relations(opticalDrivesTable, ({ one }) => ({ 237 component: one(componentsTable, { 238 fields: [opticalDrivesTable.componentId], 240 239 references: [componentsTable.id], 241 240 }), … … 249 248 })); 250 249 251 export const networkAdapterRelations = relations(networkAdapter Table, ({ one }) => ({252 component: one(componentsTable, { 253 fields: [networkAdapter Table.componentId],254 references: [componentsTable.id], 255 }), 256 })); 257 258 export const networkCardRelations = relations(networkCard Table, ({ one }) => ({259 component: one(componentsTable, { 260 fields: [networkCard Table.componentId],261 references: [componentsTable.id], 262 }), 263 })); 264 265 export const pcCaseRelations = relations(pcCase Table, ({ one, many }) => ({266 component: one(componentsTable, { 267 fields: [pcCase Table.componentId],250 export const networkAdapterRelations = relations(networkAdaptersTable, ({ one }) => ({ 251 component: one(componentsTable, { 252 fields: [networkAdaptersTable.componentId], 253 references: [componentsTable.id], 254 }), 255 })); 256 257 export const networkCardRelations = relations(networkCardsTable, ({ one }) => ({ 258 component: one(componentsTable, { 259 fields: [networkCardsTable.componentId], 260 references: [componentsTable.id], 261 }), 262 })); 263 264 export const pcCaseRelations = relations(pcCasesTable, ({ one, many }) => ({ 265 component: one(componentsTable, { 266 fields: [pcCasesTable.componentId], 268 267 references: [componentsTable.id], 269 268 }), … … 274 273 275 274 export const caseStorageFormFactorsRelations = relations(caseStorageFormFactorsTable, ({ one }) => ({ 276 pcCase: one(pcCase Table, {275 pcCase: one(pcCasesTable, { 277 276 fields: [caseStorageFormFactorsTable.caseId], 278 references: [pcCase Table.componentId],277 references: [pcCasesTable.componentId], 279 278 }), 280 279 })); 281 280 282 281 export const casePsFormFactorsRelations = relations(casePsFormFactorsTable, ({ one }) => ({ 283 pcCase: one(pcCase Table, {282 pcCase: one(pcCasesTable, { 284 283 fields: [casePsFormFactorsTable.caseId], 285 references: [pcCase Table.componentId],284 references: [pcCasesTable.componentId], 286 285 }), 287 286 })); 288 287 289 288 export const caseMoboFormFactorsRelations = relations(caseMoboFormFactorsTable, ({ one }) => ({ 290 pcCase: one(pcCase Table, {289 pcCase: one(pcCasesTable, { 291 290 fields: [caseMoboFormFactorsTable.caseId], 292 references: [pcCase Table.componentId],293 }), 294 })); 295 296 export const coolerRelations = relations(cooler Table, ({ one, many }) => ({297 component: one(componentsTable, { 298 fields: [cooler Table.componentId],291 references: [pcCasesTable.componentId], 292 }), 293 })); 294 295 export const coolerRelations = relations(coolersTable, ({ one, many }) => ({ 296 component: one(componentsTable, { 297 fields: [coolersTable.componentId], 299 298 references: [componentsTable.id], 300 299 }), … … 303 302 304 303 export const coolerCpuSocketsRelations = relations(coolerCPUSocketsTable, ({ one }) => ({ 305 cooler: one(cooler Table, {304 cooler: one(coolersTable, { 306 305 fields: [coolerCPUSocketsTable.cooler_id], 307 references: [coolerTable.componentId], 308 }), 309 })); 310 311 export const soundCardRelations = relations(soundCardTable, ({ one, many }) => ({ 312 component: one(componentsTable, { 313 fields: [soundCardTable.componentId], 314 references: [componentsTable.id], 315 }), 316 channels: many(soundCardChannelsTable), 317 })); 318 319 export const soundCardChannelsRelations = relations(soundCardChannelsTable, ({ one }) => ({ 320 soundCard: one(soundCardTable, { 321 fields: [soundCardChannelsTable.soundCardId], 322 references: [soundCardTable.componentId], 323 }), 324 })); 306 references: [coolersTable.componentId], 307 }), 308 })); 309 310 export const soundCardRelations = relations(soundCardsTable, ({ one, many }) => ({ 311 component: one(componentsTable, { 312 fields: [soundCardsTable.componentId], 313 references: [componentsTable.id], 314 }), 315 }));
Note:
See TracChangeset
for help on using the changeset viewer.
