Skip to content

Commit

Permalink
Fix linter errors
Browse files Browse the repository at this point in the history
  • Loading branch information
sashee authored and tanem committed May 11, 2021
1 parent b3e4a47 commit 02e708f
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions db/seeds/03-tags.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,10 @@ const getArticleTags = (taggedArticles) => async (knex) => {
const allTags = await knex('tags');
return taggedArticles
.map(({article, tags}) => {
return tags.map((tag) => [article, allTags.find(({name}) => name === tag).id]);
return tags.map((tag) => [
article,
allTags.find(({name}) => name === tag).id,
]);
})
.reduce((memo, arr) => memo.concat(arr), [])
.map(([article, tag]) => {
Expand All @@ -54,13 +57,11 @@ const getArticleTags = (taggedArticles) => async (knex) => {
});
};



exports.seed = async (knex) => {
const {tags, taggedArticles} = await getTags(knex);
await knex('tags').del();
await knex('tags').insert(tags);
const articleTags = await getArticleTags(taggedArticles)(knex);
await knex('articles_tags').del();
await knex('articles_tags').insert(articleTags);
}
};

0 comments on commit 02e708f

Please sign in to comment.