Skip to content

Commit

Permalink
target dir
Browse files Browse the repository at this point in the history
  • Loading branch information
ElectronSz committed Jan 14, 2024
1 parent 07fe4e8 commit 78b516f
Show file tree
Hide file tree
Showing 27 changed files with 465 additions and 21 deletions.
Binary file modified bun.lockb
Binary file not shown.
1 change: 0 additions & 1 deletion data/da.py

This file was deleted.

3 changes: 0 additions & 3 deletions data/philip.vue

This file was deleted.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"@types/jsonwebtoken": "^9.0.5",
"@types/morgan": "^1.9.9",
"bcryptjs": "^2.4.3",
"child_process": "^1.0.2",
"compression": "^1.7.4",
"express": "^4.18.2",
"jsonwebtoken": "^9.0.2",
Expand Down
49 changes: 49 additions & 0 deletions prisma/migrations/20240114132406_target/migration.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/*
Warnings:
- You are about to drop the `Source` table. If the table is not empty, all the data it contains will be lost.
- You are about to drop the `User` table. If the table is not empty, all the data it contains will be lost.
*/
-- DropForeignKey
ALTER TABLE "public"."Source" DROP CONSTRAINT "Source_userId_fkey";

-- DropTable
DROP TABLE "public"."Source";

-- DropTable
DROP TABLE "public"."User";

-- CreateTable
CREATE TABLE "User" (
"id" SERIAL NOT NULL,
"email" TEXT NOT NULL,
"password" TEXT NOT NULL,
"name" TEXT,
"status" BOOLEAN NOT NULL DEFAULT false,
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" TIMESTAMP(3) NOT NULL,

CONSTRAINT "User_pkey" PRIMARY KEY ("id")
);

-- CreateTable
CREATE TABLE "Source" (
"id" SERIAL NOT NULL,
"dir" TEXT NOT NULL,
"status" BOOLEAN NOT NULL DEFAULT false,
"userId" INTEGER NOT NULL,
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" TIMESTAMP(3) NOT NULL,

CONSTRAINT "Source_pkey" PRIMARY KEY ("id")
);

-- CreateIndex
CREATE UNIQUE INDEX "User_email_key" ON "User"("email");

-- CreateIndex
CREATE UNIQUE INDEX "Source_dir_key" ON "Source"("dir");

-- AddForeignKey
ALTER TABLE "Source" ADD CONSTRAINT "Source_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
49 changes: 49 additions & 0 deletions prisma/migrations/20240114132539_target/migration.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/*
Warnings:
- You are about to drop the `Source` table. If the table is not empty, all the data it contains will be lost.
- You are about to drop the `User` table. If the table is not empty, all the data it contains will be lost.
*/
-- DropForeignKey
ALTER TABLE "public"."Source" DROP CONSTRAINT "Source_userId_fkey";

-- DropTable
DROP TABLE "public"."Source";

-- DropTable
DROP TABLE "public"."User";

-- CreateTable
CREATE TABLE "User" (
"id" SERIAL NOT NULL,
"email" TEXT NOT NULL,
"password" TEXT NOT NULL,
"name" TEXT,
"status" BOOLEAN NOT NULL DEFAULT false,
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" TIMESTAMP(3) NOT NULL,

CONSTRAINT "User_pkey" PRIMARY KEY ("id")
);

-- CreateTable
CREATE TABLE "Source" (
"id" SERIAL NOT NULL,
"dir" TEXT NOT NULL,
"status" BOOLEAN NOT NULL DEFAULT false,
"userId" INTEGER NOT NULL,
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" TIMESTAMP(3) NOT NULL,

CONSTRAINT "Source_pkey" PRIMARY KEY ("id")
);

-- CreateIndex
CREATE UNIQUE INDEX "User_email_key" ON "User"("email");

-- CreateIndex
CREATE UNIQUE INDEX "Source_dir_key" ON "Source"("dir");

-- AddForeignKey
ALTER TABLE "Source" ADD CONSTRAINT "Source_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
67 changes: 67 additions & 0 deletions prisma/migrations/20240114132713_target/migration.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
/*
Warnings:
- You are about to drop the `Source` table. If the table is not empty, all the data it contains will be lost.
- You are about to drop the `User` table. If the table is not empty, all the data it contains will be lost.
*/
-- DropForeignKey
ALTER TABLE "public"."Source" DROP CONSTRAINT "Source_userId_fkey";

-- DropTable
DROP TABLE "public"."Source";

-- DropTable
DROP TABLE "public"."User";

-- CreateTable
CREATE TABLE "User" (
"id" SERIAL NOT NULL,
"email" TEXT NOT NULL,
"password" TEXT NOT NULL,
"name" TEXT,
"status" BOOLEAN NOT NULL DEFAULT false,
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" TIMESTAMP(3) NOT NULL,

CONSTRAINT "User_pkey" PRIMARY KEY ("id")
);

-- CreateTable
CREATE TABLE "Source" (
"id" SERIAL NOT NULL,
"dir" TEXT NOT NULL,
"status" BOOLEAN NOT NULL DEFAULT false,
"userId" INTEGER NOT NULL,
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" TIMESTAMP(3) NOT NULL,

CONSTRAINT "Source_pkey" PRIMARY KEY ("id")
);

-- CreateTable
CREATE TABLE "Target" (
"id" SERIAL NOT NULL,
"dir" TEXT NOT NULL,
"status" BOOLEAN NOT NULL DEFAULT false,
"userId" INTEGER NOT NULL,
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" TIMESTAMP(3) NOT NULL,

CONSTRAINT "Target_pkey" PRIMARY KEY ("id")
);

-- CreateIndex
CREATE UNIQUE INDEX "User_email_key" ON "User"("email");

-- CreateIndex
CREATE UNIQUE INDEX "Source_dir_key" ON "Source"("dir");

-- CreateIndex
CREATE UNIQUE INDEX "Target_dir_key" ON "Target"("dir");

-- AddForeignKey
ALTER TABLE "Source" ADD CONSTRAINT "Source_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "Target" ADD CONSTRAINT "Target_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
77 changes: 77 additions & 0 deletions prisma/migrations/20240114133025_target/migration.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
/*
Warnings:
- You are about to drop the `Source` table. If the table is not empty, all the data it contains will be lost.
- You are about to drop the `Target` table. If the table is not empty, all the data it contains will be lost.
- You are about to drop the `User` table. If the table is not empty, all the data it contains will be lost.
*/
-- DropForeignKey
ALTER TABLE "public"."Source" DROP CONSTRAINT "Source_userId_fkey";

-- DropForeignKey
ALTER TABLE "public"."Target" DROP CONSTRAINT "Target_userId_fkey";

-- DropTable
DROP TABLE "public"."Source";

-- DropTable
DROP TABLE "public"."Target";

-- DropTable
DROP TABLE "public"."User";

-- CreateTable
CREATE TABLE "User" (
"id" SERIAL NOT NULL,
"email" TEXT NOT NULL,
"password" TEXT NOT NULL,
"name" TEXT,
"status" BOOLEAN NOT NULL DEFAULT false,
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" TIMESTAMP(3) NOT NULL,

CONSTRAINT "User_pkey" PRIMARY KEY ("id")
);

-- CreateTable
CREATE TABLE "Source" (
"id" SERIAL NOT NULL,
"dir" TEXT NOT NULL,
"status" BOOLEAN NOT NULL DEFAULT false,
"userId" INTEGER NOT NULL,
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" TIMESTAMP(3) NOT NULL,

CONSTRAINT "Source_pkey" PRIMARY KEY ("id")
);

-- CreateTable
CREATE TABLE "Target" (
"id" SERIAL NOT NULL,
"dir" TEXT NOT NULL,
"status" BOOLEAN NOT NULL DEFAULT false,
"userId" INTEGER NOT NULL,
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" TIMESTAMP(3) NOT NULL,

CONSTRAINT "Target_pkey" PRIMARY KEY ("id")
);

-- CreateIndex
CREATE UNIQUE INDEX "User_email_key" ON "User"("email");

-- CreateIndex
CREATE UNIQUE INDEX "Source_dir_key" ON "Source"("dir");

-- CreateIndex
CREATE UNIQUE INDEX "Target_dir_key" ON "Target"("dir");

-- CreateIndex
CREATE UNIQUE INDEX "Target_userId_key" ON "Target"("userId");

-- AddForeignKey
ALTER TABLE "Source" ADD CONSTRAINT "Source_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "Target" ADD CONSTRAINT "Target_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
77 changes: 77 additions & 0 deletions prisma/migrations/20240114133200_target/migration.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
/*
Warnings:
- You are about to drop the `Source` table. If the table is not empty, all the data it contains will be lost.
- You are about to drop the `Target` table. If the table is not empty, all the data it contains will be lost.
- You are about to drop the `User` table. If the table is not empty, all the data it contains will be lost.
*/
-- DropForeignKey
ALTER TABLE "public"."Source" DROP CONSTRAINT "Source_userId_fkey";

-- DropForeignKey
ALTER TABLE "public"."Target" DROP CONSTRAINT "Target_userId_fkey";

-- DropTable
DROP TABLE "public"."Source";

-- DropTable
DROP TABLE "public"."Target";

-- DropTable
DROP TABLE "public"."User";

-- CreateTable
CREATE TABLE "User" (
"id" SERIAL NOT NULL,
"email" TEXT NOT NULL,
"password" TEXT NOT NULL,
"name" TEXT,
"status" BOOLEAN NOT NULL DEFAULT false,
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" TIMESTAMP(3) NOT NULL,

CONSTRAINT "User_pkey" PRIMARY KEY ("id")
);

-- CreateTable
CREATE TABLE "Source" (
"id" SERIAL NOT NULL,
"dir" TEXT NOT NULL,
"status" BOOLEAN NOT NULL DEFAULT false,
"userId" INTEGER NOT NULL,
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" TIMESTAMP(3) NOT NULL,

CONSTRAINT "Source_pkey" PRIMARY KEY ("id")
);

-- CreateTable
CREATE TABLE "Target" (
"id" SERIAL NOT NULL,
"dir" TEXT NOT NULL,
"status" BOOLEAN NOT NULL DEFAULT false,
"userId" INTEGER NOT NULL,
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" TIMESTAMP(3) NOT NULL,

CONSTRAINT "Target_pkey" PRIMARY KEY ("id")
);

-- CreateIndex
CREATE UNIQUE INDEX "User_email_key" ON "User"("email");

-- CreateIndex
CREATE UNIQUE INDEX "Source_dir_key" ON "Source"("dir");

-- CreateIndex
CREATE UNIQUE INDEX "Target_dir_key" ON "Target"("dir");

-- CreateIndex
CREATE UNIQUE INDEX "Target_userId_key" ON "Target"("userId");

-- AddForeignKey
ALTER TABLE "Source" ADD CONSTRAINT "Source_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "Target" ADD CONSTRAINT "Target_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
11 changes: 11 additions & 0 deletions prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ model User {
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
Source Source[]
Target Target?
}

model Source {
Expand All @@ -28,3 +29,13 @@ model Source {
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
}

model Target {
id Int @id @default(autoincrement())
dir String @unique
status Boolean @default(false)
userId Int @unique
user User @relation(fields: [userId], references: [id])
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
}
10 changes: 8 additions & 2 deletions src/models/Source.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,13 @@ const getSources = async (userId: number) => {
}
});

return sources;
const sourceArr: string[] = []

sources.forEach(source => {
sourceArr.push(source.dir)
});

return sourceArr;
}

//create source for user
Expand All @@ -18,7 +24,7 @@ const createSource = async (source: any) => {
const userId = source.userId;
delete source["userId"];

const createdSource = await db.source.create({
const createdSource: Source = await db.source.create({
data: {
...source,
user: {
Expand Down
Loading

0 comments on commit 78b516f

Please sign in to comment.