ituriel
ituriel
KKysely
Created by ituriel on 12/29/2023 in #help
How to handle versioning of database objects.
Hello, i want to add versioning for my QuizTemplates. I have an idea with revision field. I want to add new field called "revision" in quizTemplate and quizInstance somehow create join from QuizInstance. How can i create join by two fields instead of one? How do you handle join by more than 1 column. model QuizTemplate { id Int @id @default(autoincrement()) createdAt DateTime @default(now()) title String description String content Json ownerId String // revision Int quizInstances QuizInstance[] } model QuizInstance { id Int @id @default(autoincrement()) createdAt DateTime @default(now()) done Boolean title String description String // revision Int templateId Int quizTemplate QuizTemplate @relation(fields: [templateId], references: [id]) } const quiz = await db .selectFrom("QuizInstance") .innerJoin("QuizTemplate", "QuizTemplate.id", "QuizInstance.templateId") .where("QuizInstance.id", "=", instanceId) .select([ "done", "QuizTemplate.content", "QuizInstance.title", "QuizInstance.description", "QuizInstance.id", ]) .executeTakeFirstOrThrow();
5 replies