Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support MongoDB #49

Merged
merged 5 commits into from
Jan 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion backend/.env
Original file line number Diff line number Diff line change
@@ -1 +1 @@
DATABASE_URL="file:./dev.db"
DATABASE_URL="mongodb://localhost:27017/codepair"
64 changes: 32 additions & 32 deletions backend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"@nestjs/core": "^10.0.0",
"@nestjs/platform-express": "^10.0.0",
"@nestjs/swagger": "^7.1.17",
"@prisma/client": "^5.8.0",
"@prisma/client": "^5.8.1",
"reflect-metadata": "^0.1.13",
"rxjs": "^7.8.1"
},
Expand All @@ -44,7 +44,7 @@
"eslint-plugin-prettier": "^5.0.0",
"jest": "^29.5.0",
"prettier": "^3.0.0",
"prisma": "^5.8.0",
"prisma": "^5.8.1",
"source-map-support": "^0.5.21",
"supertest": "^6.3.3",
"ts-jest": "^29.1.0",
Expand Down
43 changes: 0 additions & 43 deletions backend/prisma/migrations/20240115062824_init/migration.sql

This file was deleted.

3 changes: 0 additions & 3 deletions backend/prisma/migrations/migration_lock.toml

This file was deleted.

54 changes: 31 additions & 23 deletions backend/prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -6,46 +6,54 @@ generator client {
}

datasource db {
provider = "sqlite"
provider = "mongodb"
url = env("DATABASE_URL")
}

model User {
id Int @id @default(autoincrement())
socialUid String @unique
nickname String
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
UserWorkspace UserWorkspace[]
id String @id @default(auto()) @map("_id") @db.ObjectId
socialProvider String @map("social_provider")
socialUid String @unique @map("social_uid")
nickname String
createdAt DateTime @default(now()) @map("created_at")
updatedAt DateTime @updatedAt @map("updated_at")
UserWorkspace UserWorkspace[]

@@map("users")
}

model UserWorkspace {
id String @id @default(auto()) @map("_id") @db.ObjectId
user User @relation(fields: [userId], references: [id])
userId Int
userId String @map("user_id") @db.ObjectId
workspace Workspace @relation(fields: [workspaceId], references: [id])
workspaceId Int
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
workspaceId String @map("workspace_id") @db.ObjectId
createdAt DateTime @default(now()) @map("created_at")
updatedAt DateTime @updatedAt @map("updated_at")

@@id([userId, workspaceId])
@@map("user_workspaces")
}

model Workspace {
id Int @id @default(autoincrement())
title String
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
documentList Document[]
UserWorkspace UserWorkspace[]
id String @id @default(auto()) @map("_id") @db.ObjectId
title String
createdAt DateTime @default(now()) @map("created_at")
updatedAt DateTime @updatedAt @map("updated_at")
documentList Document[]
userWorkspaceList UserWorkspace[]

@@map("workspaces")
}

model Document {
id Int @id @default(autoincrement())
yorkieDocumentId String
id String @id @default(auto()) @map("_id") @db.ObjectId
yorkieDocumentId String @map("yorkie_document_id")
title String
content String?
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
createdAt DateTime @default(now()) @map("created_at")
updatedAt DateTime @updatedAt @map("updated_at")
workspace Workspace @relation(fields: [workspaceId], references: [id])
workspaceId Int
workspaceId String @map("workspace_id") @db.ObjectId

@@map("documents")
}
Loading