diff --git a/.prettierrc b/.prettierrc new file mode 100644 index 0000000..46be197 --- /dev/null +++ b/.prettierrc @@ -0,0 +1,4 @@ +trailingComma: "es5" +tabWidth: 2 +semi: false +singleQuote: true diff --git a/db/models/index.js b/db/models/index.js index 9a75ca5..0bea56a 100755 --- a/db/models/index.js +++ b/db/models/index.js @@ -1,6 +1,6 @@ const Comment = require('./comment') -Comment.belongsTo(Comment, {as: 'parent'}) -Comment.belongsToMany(Comment, {through: 'CommentReplies', as: { singular: 'reply', plural: 'replies' } }) +Comment.belongsTo(Comment, { as: 'parent' }) +Comment.hasMany(Comment, { as: { singular: 'reply', plural: 'replies' } }) -module.exports = {Comment} +module.exports = { Comment } diff --git a/db/seed.js b/db/seed.js index 6b27bd0..5d65431 100755 --- a/db/seed.js +++ b/db/seed.js @@ -4,9 +4,9 @@ const { Comment } = require('./models') const tc1 = {text: 'c1'} const tc2 = {text: 'c2'} const tc3 = {text: 'c3'} -// const tc4 = {text: 'c4'} -// const tc5 = {text: 'c5'} -// const tc6 = {text: 'c6'} +const tc4 = {text: 'c4'} +const tc5 = {text: 'c5'} +const tc6 = {text: 'c6'} async function runSeed() { @@ -17,15 +17,18 @@ async function runSeed() { const c1 = await Comment.create(tc1) const c2 = await Comment.create(tc2) const c3 = await Comment.create(tc3) - // const c4 = await Comment.create(tc4) - // const c5 = await Comment.create(tc5) - // const c6 = await Comment.create(tc6) + const c4 = await Comment.create(tc4) + const c5 = await Comment.create(tc5) + const c6 = await Comment.create(tc6) await c1.addReply(2) - await c2.setParent(1) + //await c2.setParent(1) await c2.addReply(3) - await c3.setParent(2) + //await c3.setParent(2) + //await c4.setParent(2) + + console.log('seeded successfully') } catch (err) {