From 74a4d01fcc491aeb99698e88aa213cf3e70391e0 Mon Sep 17 00:00:00 2001 From: monoid Date: Wed, 6 Jan 2021 22:10:01 +0900 Subject: [PATCH] fix contents --- seeds/initseed.ts | 20 -------------------- src/db/contents.ts | 1 + 2 files changed, 1 insertion(+), 20 deletions(-) delete mode 100644 seeds/initseed.ts diff --git a/seeds/initseed.ts b/seeds/initseed.ts deleted file mode 100644 index b91ed7c..0000000 --- a/seeds/initseed.ts +++ /dev/null @@ -1,20 +0,0 @@ -import Knex from "knex"; - -exports.seed = async function(knex:Knex) { - // Deletes ALL existing entries - await knex('contents').del(); - await knex('contents').insert({ - title:"aaa", - basepath:"testdata", - content_type:"manga", - filename:"test_zip.zip", - additional:JSON.stringify({comment:"comment"}) - }); - await knex('contents').insert({ - title:"aaa", - basepath:"testdata", - content_type:"video", - filename:"video_test.mp4", - additional:JSON.stringify({comment:"test comment"}) - }); -}; diff --git a/src/db/contents.ts b/src/db/contents.ts index 485fd5b..95ae9f4 100644 --- a/src/db/contents.ts +++ b/src/db/contents.ts @@ -34,6 +34,7 @@ class KnexContentsAccessor implements ContentAccessor{ }; async del(id:number) { if (await this.findById(id) !== undefined){ + await this.knex.delete().from("content_tag_relation").where({content_id:id}); await this.knex.delete().from("contents").where({id:id}); return true; }