-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
282 additions
and
133 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,62 +1,62 @@ | ||
import { tableNames } from "@/v2/db/drizzle" | ||
import { relations } from "drizzle-orm" | ||
import { index, sqliteTable, text } from "drizzle-orm/sqlite-core" | ||
import { authUser } from "../user/user" | ||
import { createInsertSchema, createSelectSchema } from "drizzle-zod" | ||
import { assetCategory } from "./asset-categories" | ||
// import { tableNames } from "@/v2/db/drizzle" | ||
// import { relations } from "drizzle-orm" | ||
// import { index, sqliteTable, text } from "drizzle-orm/sqlite-core" | ||
// import { authUser } from "../user/user" | ||
// import { createInsertSchema, createSelectSchema } from "drizzle-zod" | ||
// import { assetCategory } from "./asset-categories" | ||
|
||
export const assetCategoryLikes = sqliteTable( | ||
tableNames.assetCategoryLikes, | ||
{ | ||
assetCategoryId: text("asset_id") | ||
.notNull() | ||
.references(() => assetCategory.id, { | ||
onUpdate: "cascade", | ||
onDelete: "cascade", | ||
}), | ||
likedById: text("liked_by_id") | ||
.notNull() | ||
.references(() => authUser.id, { | ||
onUpdate: "cascade", | ||
onDelete: "cascade", | ||
}), | ||
createdAt: text("created_at") | ||
.notNull() | ||
.$defaultFn(() => { | ||
return new Date().toISOString() | ||
}), | ||
}, | ||
(gameLikes) => { | ||
return { | ||
assetCategoryIdx: index("assetCategoryLikes_asset_idx").on( | ||
gameLikes.assetCategoryId | ||
), | ||
likedByIdx: index("assetCategoryLikes_likedby_idx").on( | ||
gameLikes.likedById | ||
), | ||
} | ||
} | ||
) | ||
// export const assetCategoryLikes = sqliteTable( | ||
// tableNames.assetCategoryLikes, | ||
// { | ||
// assetCategoryId: text("asset_id") | ||
// .notNull() | ||
// .references(() => assetCategory.id, { | ||
// onUpdate: "cascade", | ||
// onDelete: "cascade", | ||
// }), | ||
// likedById: text("liked_by_id") | ||
// .notNull() | ||
// .references(() => authUser.id, { | ||
// onUpdate: "cascade", | ||
// onDelete: "cascade", | ||
// }), | ||
// createdAt: text("created_at") | ||
// .notNull() | ||
// .$defaultFn(() => { | ||
// return new Date().toISOString() | ||
// }), | ||
// }, | ||
// (gameLikes) => { | ||
// return { | ||
// assetCategoryIdx: index("assetCategoryLikes_asset_idx").on( | ||
// gameLikes.assetCategoryId | ||
// ), | ||
// likedByIdx: index("assetCategoryLikes_likedby_idx").on( | ||
// gameLikes.likedById | ||
// ), | ||
// } | ||
// } | ||
// ) | ||
|
||
export type AssetCategoryLikes = typeof assetCategoryLikes.$inferSelect | ||
export type NewAssetCategoryLikes = typeof assetCategoryLikes.$inferInsert | ||
export const insertAssetCategoryLikesSchema = | ||
createInsertSchema(assetCategoryLikes) | ||
export const selectAssetCategoryLikesSchema = | ||
createSelectSchema(assetCategoryLikes) | ||
// export type AssetCategoryLikes = typeof assetCategoryLikes.$inferSelect | ||
// export type NewAssetCategoryLikes = typeof assetCategoryLikes.$inferInsert | ||
// export const insertAssetCategoryLikesSchema = | ||
// createInsertSchema(assetCategoryLikes) | ||
// export const selectAssetCategoryLikesSchema = | ||
// createSelectSchema(assetCategoryLikes) | ||
|
||
export const assetCategoryLikesRelations = relations( | ||
assetCategoryLikes, | ||
({ one }) => ({ | ||
assetCategory: one(assetCategory, { | ||
fields: [assetCategoryLikes.assetCategoryId], | ||
references: [assetCategory.id], | ||
relationName: "assetCategoryLikes_liked_assetCategory", | ||
}), | ||
likedBy: one(authUser, { | ||
fields: [assetCategoryLikes.likedById], | ||
references: [authUser.id], | ||
relationName: "assetTagLikes_liked_by", | ||
}), | ||
}) | ||
) | ||
// export const assetCategoryLikesRelations = relations( | ||
// assetCategoryLikes, | ||
// ({ one }) => ({ | ||
// assetCategory: one(assetCategory, { | ||
// fields: [assetCategoryLikes.assetCategoryId], | ||
// references: [assetCategory.id], | ||
// relationName: "assetCategoryLikes_liked_assetCategory", | ||
// }), | ||
// likedBy: one(authUser, { | ||
// fields: [assetCategoryLikes.likedById], | ||
// references: [authUser.id], | ||
// relationName: "assetTagLikes_liked_by", | ||
// }), | ||
// }) | ||
// ) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,53 +1,53 @@ | ||
import { tableNames } from "@/v2/db/drizzle" | ||
import { relations } from "drizzle-orm" | ||
import { index, sqliteTable, text } from "drizzle-orm/sqlite-core" | ||
import { authUser } from "../user/user" | ||
import { game } from "./game" | ||
import { createInsertSchema, createSelectSchema } from "drizzle-zod" | ||
// import { tableNames } from "@/v2/db/drizzle" | ||
// import { relations } from "drizzle-orm" | ||
// import { index, sqliteTable, text } from "drizzle-orm/sqlite-core" | ||
// import { authUser } from "../user/user" | ||
// import { game } from "./game" | ||
// import { createInsertSchema, createSelectSchema } from "drizzle-zod" | ||
|
||
export const gameLikes = sqliteTable( | ||
tableNames.gameLikes, | ||
{ | ||
gameId: text("asset_id") | ||
.notNull() | ||
.references(() => game.id, { | ||
onUpdate: "cascade", | ||
onDelete: "cascade", | ||
}), | ||
likedById: text("liked_by_id") | ||
.notNull() | ||
.references(() => authUser.id, { | ||
onUpdate: "cascade", | ||
onDelete: "cascade", | ||
}), | ||
createdAt: text("created_at") | ||
.notNull() | ||
.$defaultFn(() => { | ||
return new Date().toISOString() | ||
}), | ||
}, | ||
(gameLikes) => { | ||
return { | ||
gameIdx: index("gamelikes_game_idx").on(gameLikes.gameId), | ||
likedByIdx: index("gamelikes_likedby_idx").on(gameLikes.likedById), | ||
} | ||
} | ||
) | ||
// export const gameLikes = sqliteTable( | ||
// tableNames.gameLikes, | ||
// { | ||
// gameId: text("asset_id") | ||
// .notNull() | ||
// .references(() => game.id, { | ||
// onUpdate: "cascade", | ||
// onDelete: "cascade", | ||
// }), | ||
// likedById: text("liked_by_id") | ||
// .notNull() | ||
// .references(() => authUser.id, { | ||
// onUpdate: "cascade", | ||
// onDelete: "cascade", | ||
// }), | ||
// createdAt: text("created_at") | ||
// .notNull() | ||
// .$defaultFn(() => { | ||
// return new Date().toISOString() | ||
// }), | ||
// }, | ||
// (gameLikes) => { | ||
// return { | ||
// gameIdx: index("gamelikes_game_idx").on(gameLikes.gameId), | ||
// likedByIdx: index("gamelikes_likedby_idx").on(gameLikes.likedById), | ||
// } | ||
// } | ||
// ) | ||
|
||
export type GameLikes = typeof gameLikes.$inferSelect | ||
export type NewGameLikes = typeof gameLikes.$inferInsert | ||
export const insertGameLikesSchema = createInsertSchema(gameLikes) | ||
export const selectGameLikesSchema = createSelectSchema(gameLikes) | ||
// export type GameLikes = typeof gameLikes.$inferSelect | ||
// export type NewGameLikes = typeof gameLikes.$inferInsert | ||
// export const insertGameLikesSchema = createInsertSchema(gameLikes) | ||
// export const selectGameLikesSchema = createSelectSchema(gameLikes) | ||
|
||
export const gameLikesRelations = relations(gameLikes, ({ one }) => ({ | ||
game: one(game, { | ||
fields: [gameLikes.gameId], | ||
references: [game.id], | ||
relationName: "gamelikes_liked_game", | ||
}), | ||
likedBy: one(authUser, { | ||
fields: [gameLikes.likedById], | ||
references: [authUser.id], | ||
relationName: "gamelikes_liked_by", | ||
}), | ||
})) | ||
// export const gameLikesRelations = relations(gameLikes, ({ one }) => ({ | ||
// game: one(game, { | ||
// fields: [gameLikes.gameId], | ||
// references: [game.id], | ||
// relationName: "gamelikes_liked_game", | ||
// }), | ||
// likedBy: one(authUser, { | ||
// fields: [gameLikes.likedById], | ||
// references: [authUser.id], | ||
// relationName: "gamelikes_liked_by", | ||
// }), | ||
// })) |
Oops, something went wrong.