diff --git a/src/graphql-schema.spec.js b/src/graphql-schema.spec.js index 3d259ab42..7aa47835f 100644 --- a/src/graphql-schema.spec.js +++ b/src/graphql-schema.spec.js @@ -6,7 +6,7 @@ import { host, login } from './jest/helpers' const factory = Factory() beforeEach(async () => { - await factory.create('user', { + await factory.create('User', { email: 'test@example.org', password: '1234' }) @@ -122,11 +122,11 @@ describe('CreatePost', () => { describe('report', () => { beforeEach(async () => { - await factory.create('user', { + await factory.create('User', { email: 'test@example.org', password: '1234' }) - await factory.create('user', { + await factory.create('User', { id: 'u2', name: 'abusive-user', role: 'user', diff --git a/src/middleware/permissionsMiddleware.spec.js b/src/middleware/permissionsMiddleware.spec.js index a22f2bb72..78766aad2 100644 --- a/src/middleware/permissionsMiddleware.spec.js +++ b/src/middleware/permissionsMiddleware.spec.js @@ -7,12 +7,12 @@ const factory = Factory() describe('authorization', () => { describe('given two existing users', () => { beforeEach(async () => { - await factory.create('user', { + await factory.create('User', { email: 'owner@example.org', name: 'Owner', password: 'iamtheowner' }) - await factory.create('user', { + await factory.create('User', { email: 'someone@example.org', name: 'Someone else', password: 'else' diff --git a/src/middleware/slugifyMiddleware.spec.js b/src/middleware/slugifyMiddleware.spec.js index aaa09d29a..c7cd9806f 100644 --- a/src/middleware/slugifyMiddleware.spec.js +++ b/src/middleware/slugifyMiddleware.spec.js @@ -7,8 +7,8 @@ let headers const factory = Factory() beforeEach(async () => { - await factory.create('user', { email: 'user@example.org', password: '1234' }) - await factory.create('user', { email: 'someone@example.org', password: '1234' }) + await factory.create('User', { email: 'user@example.org', password: '1234' }) + await factory.create('User', { email: 'someone@example.org', password: '1234' }) headers = await login({ email: 'user@example.org', password: '1234' }) authenticatedClient = new GraphQLClient(host, { headers }) }) @@ -35,7 +35,7 @@ describe('slugify', () => { email: 'someone@example.org', password: '1234' }) - await asSomeoneElse.create('post', { + await asSomeoneElse.create('Post', { title: 'Pre-existing post', slug: 'pre-existing-post' }) diff --git a/src/seed/factories/comments.js b/src/seed/factories/comments.js index acf493f6d..92dca5b14 100644 --- a/src/seed/factories/comments.js +++ b/src/seed/factories/comments.js @@ -23,15 +23,3 @@ export default function (params) { } ` } - -export function relate (type, params) { - const { from, to } = params - return ` - mutation { - ${from}_${type}_${to}: AddComment${type}( - from: { id: "${from}" }, - to: { id: "${to}" } - ) { from { id } } - } - ` -} diff --git a/src/seed/factories/index.js b/src/seed/factories/index.js index a107fc6b7..752ae3369 100644 --- a/src/seed/factories/index.js +++ b/src/seed/factories/index.js @@ -1,6 +1,15 @@ import { GraphQLClient, request } from 'graphql-request' import { getDriver } from '../../bootstrap/neo4j' +import createBadge from './badges.js' +import createUser from './users.js' +import createOrganization from './organizations.js' +import createPost from './posts.js' +import createComment from './comments.js' +import createCategory from './categories.js' +import createTag from './tags.js' +import createReport from './reports.js' + export const seedServerHost = 'http://127.0.0.1:4001' const authenticatedHeaders = async ({ email, password }, host) => { @@ -15,35 +24,15 @@ const authenticatedHeaders = async ({ email, password }, host) => { authorization: `Bearer ${response.login.token}` } } - const factories = { - 'badge': require('./badges.js').default, - 'user': require('./users.js').default, - 'organization': require('./organizations.js').default, - 'post': require('./posts.js').default, - 'comment': require('./comments.js').default, - 'category': require('./categories.js').default, - 'tag': require('./tags.js').default, - 'report': require('./reports.js').default -} - -const relationFactories = { - 'user': require('./users.js').relate, - 'organization': require('./organizations.js').relate, - 'post': require('./posts.js').relate, - 'comment': require('./comments.js').relate -} - -export const create = (model, parameters, options) => { - const graphQLClient = new GraphQLClient(seedServerHost, options) - const mutation = factories[model](parameters) - return graphQLClient.request(mutation) -} - -export const relate = (model, type, parameters, options) => { - const graphQLClient = new GraphQLClient(seedServerHost, options) - const mutation = relationFactories[model](type, parameters) - return graphQLClient.request(mutation) + 'Badge': createBadge, + 'User': createUser, + 'Organization': createOrganization, + 'Post': createPost, + 'Comment': createComment, + 'Category': createCategory, + 'Tag': createTag, + 'Report': createReport } export const cleanDatabase = async (options = {}) => { @@ -73,6 +62,7 @@ export default function Factory (options = {}) { neo4jDriver, seedServerHost, graphQLClient, + factories, lastResponse: null, async authenticateAs ({ email, password }) { const headers = await authenticatedHeaders({ email, password }, seedServerHost) @@ -81,12 +71,20 @@ export default function Factory (options = {}) { return this }, async create (node, properties) { - const mutation = factories[node](properties) + const mutation = this.factories[node](properties) this.lastResponse = await this.graphQLClient.request(mutation) return this }, async relate (node, relationship, properties) { - const mutation = relationFactories[node](relationship, properties) + const { from, to } = properties + const mutation = ` + mutation { + Add${node}${relationship}( + from: { id: "${from}" }, + to: { id: "${to}" } + ) { from { id } } + } + ` this.lastResponse = await this.graphQLClient.request(mutation) return this }, diff --git a/src/seed/factories/organizations.js b/src/seed/factories/organizations.js index 0ab73beb8..783edac26 100644 --- a/src/seed/factories/organizations.js +++ b/src/seed/factories/organizations.js @@ -22,15 +22,3 @@ export default function create (params) { } ` } - -export function relate (type, params) { - const { from, to } = params - return ` - mutation { - ${from}_${type}_${to}: AddOrganization${type}( - from: { id: "${from}" }, - to: { id: "${to}" } - ) { from { id } } - } - ` -} diff --git a/src/seed/factories/posts.js b/src/seed/factories/posts.js index 80f5e289d..d96cf4f73 100644 --- a/src/seed/factories/posts.js +++ b/src/seed/factories/posts.js @@ -32,15 +32,3 @@ export default function (params) { } ` } - -export function relate (type, params) { - const { from, to } = params - return ` - mutation { - ${from}_${type}_${to}: AddPost${type}( - from: { id: "${from}" }, - to: { id: "${to}" } - ) { from { id } } - } - ` -} diff --git a/src/seed/factories/users.js b/src/seed/factories/users.js index b3a6e83c1..8e0ee693c 100644 --- a/src/seed/factories/users.js +++ b/src/seed/factories/users.js @@ -33,15 +33,3 @@ export default function create (params) { } ` } - -export function relate (type, params) { - const { from, to } = params - return ` - mutation { - ${from}_${type}_${to}: AddUser${type}( - from: { id: "${from}" }, - to: { id: "${to}" } - ) { from { id } } - } - ` -} diff --git a/src/seed/seed-db.js b/src/seed/seed-db.js index 58984b12a..b2ee8fbdb 100644 --- a/src/seed/seed-db.js +++ b/src/seed/seed-db.js @@ -1,72 +1,73 @@ -import Factory, { create, relate } from './factories' +import Factory from './factories' /* eslint-disable no-multi-spaces */ (async function () { try { + const f = Factory() await Promise.all([ - create('badge', { id: 'b1', key: 'indiegogo_en_racoon', type: 'crowdfunding', status: 'permanent', icon: '/img/badges/indiegogo_en_racoon.svg' }), - create('badge', { id: 'b2', key: 'indiegogo_en_rabbit', type: 'crowdfunding', status: 'permanent', icon: '/img/badges/indiegogo_en_rabbit.svg' }), - create('badge', { id: 'b3', key: 'indiegogo_en_wolf', type: 'crowdfunding', status: 'permanent', icon: '/img/badges/indiegogo_en_wolf.svg' }), - create('badge', { id: 'b4', key: 'indiegogo_en_bear', type: 'crowdfunding', status: 'permanent', icon: '/img/badges/indiegogo_en_bear.svg' }), - create('badge', { id: 'b5', key: 'indiegogo_en_turtle', type: 'crowdfunding', status: 'permanent', icon: '/img/badges/indiegogo_en_turtle.svg' }), - create('badge', { id: 'b6', key: 'indiegogo_en_rhino', type: 'crowdfunding', status: 'permanent', icon: '/img/badges/indiegogo_en_rhino.svg' }) + f.create('Badge', { id: 'b1', key: 'indiegogo_en_racoon', type: 'crowdfunding', status: 'permanent', icon: '/img/badges/indiegogo_en_racoon.svg' }), + f.create('Badge', { id: 'b2', key: 'indiegogo_en_rabbit', type: 'crowdfunding', status: 'permanent', icon: '/img/badges/indiegogo_en_rabbit.svg' }), + f.create('Badge', { id: 'b3', key: 'indiegogo_en_wolf', type: 'crowdfunding', status: 'permanent', icon: '/img/badges/indiegogo_en_wolf.svg' }), + f.create('Badge', { id: 'b4', key: 'indiegogo_en_bear', type: 'crowdfunding', status: 'permanent', icon: '/img/badges/indiegogo_en_bear.svg' }), + f.create('Badge', { id: 'b5', key: 'indiegogo_en_turtle', type: 'crowdfunding', status: 'permanent', icon: '/img/badges/indiegogo_en_turtle.svg' }), + f.create('Badge', { id: 'b6', key: 'indiegogo_en_rhino', type: 'crowdfunding', status: 'permanent', icon: '/img/badges/indiegogo_en_rhino.svg' }) ]) await Promise.all([ - create('user', { id: 'u1', name: 'Peter Lustig', role: 'admin', email: 'admin@example.org' }), - create('user', { id: 'u2', name: 'Bob der Baumeister', role: 'moderator', email: 'moderator@example.org' }), - create('user', { id: 'u3', name: 'Jenny Rostock', role: 'user', email: 'user@example.org' }), - create('user', { id: 'u4', name: 'Tick', role: 'user', email: 'tick@example.org' }), - create('user', { id: 'u5', name: 'Trick', role: 'user', email: 'trick@example.org' }), - create('user', { id: 'u6', name: 'Track', role: 'user', email: 'track@example.org' }), - create('user', { id: 'u7', name: 'Dagobert', role: 'user', email: 'dagobert@example.org' }) + f.create('User', { id: 'u1', name: 'Peter Lustig', role: 'admin', email: 'admin@example.org' }), + f.create('User', { id: 'u2', name: 'Bob der Baumeister', role: 'moderator', email: 'moderator@example.org' }), + f.create('User', { id: 'u3', name: 'Jenny Rostock', role: 'user', email: 'user@example.org' }), + f.create('User', { id: 'u4', name: 'Tick', role: 'user', email: 'tick@example.org' }), + f.create('User', { id: 'u5', name: 'Trick', role: 'user', email: 'trick@example.org' }), + f.create('User', { id: 'u6', name: 'Track', role: 'user', email: 'track@example.org' }), + f.create('User', { id: 'u7', name: 'Dagobert', role: 'user', email: 'dagobert@example.org' }) ]) await Promise.all([ - relate('user', 'Badges', { from: 'b6', to: 'u1' }), - relate('user', 'Badges', { from: 'b5', to: 'u2' }), - relate('user', 'Badges', { from: 'b4', to: 'u3' }), - relate('user', 'Badges', { from: 'b3', to: 'u4' }), - relate('user', 'Badges', { from: 'b2', to: 'u5' }), - relate('user', 'Badges', { from: 'b1', to: 'u6' }), - relate('user', 'Following', { from: 'u1', to: 'u2' }), - relate('user', 'Following', { from: 'u2', to: 'u3' }), - relate('user', 'Following', { from: 'u3', to: 'u4' }), - relate('user', 'Following', { from: 'u4', to: 'u5' }), - relate('user', 'Following', { from: 'u5', to: 'u6' }), - relate('user', 'Following', { from: 'u6', to: 'u7' }), - relate('user', 'Friends', { from: 'u1', to: 'u2' }), - relate('user', 'Friends', { from: 'u1', to: 'u3' }), - relate('user', 'Friends', { from: 'u2', to: 'u3' }), - relate('user', 'Blacklisted', { from: 'u7', to: 'u4' }), - relate('user', 'Blacklisted', { from: 'u7', to: 'u5' }), - relate('user', 'Blacklisted', { from: 'u7', to: 'u6' }) + f.relate('User', 'Badges', { from: 'b6', to: 'u1' }), + f.relate('User', 'Badges', { from: 'b5', to: 'u2' }), + f.relate('User', 'Badges', { from: 'b4', to: 'u3' }), + f.relate('User', 'Badges', { from: 'b3', to: 'u4' }), + f.relate('User', 'Badges', { from: 'b2', to: 'u5' }), + f.relate('User', 'Badges', { from: 'b1', to: 'u6' }), + f.relate('User', 'Following', { from: 'u1', to: 'u2' }), + f.relate('User', 'Following', { from: 'u2', to: 'u3' }), + f.relate('User', 'Following', { from: 'u3', to: 'u4' }), + f.relate('User', 'Following', { from: 'u4', to: 'u5' }), + f.relate('User', 'Following', { from: 'u5', to: 'u6' }), + f.relate('User', 'Following', { from: 'u6', to: 'u7' }), + f.relate('User', 'Friends', { from: 'u1', to: 'u2' }), + f.relate('User', 'Friends', { from: 'u1', to: 'u3' }), + f.relate('User', 'Friends', { from: 'u2', to: 'u3' }), + f.relate('User', 'Blacklisted', { from: 'u7', to: 'u4' }), + f.relate('User', 'Blacklisted', { from: 'u7', to: 'u5' }), + f.relate('User', 'Blacklisted', { from: 'u7', to: 'u6' }) ]) await Promise.all([ - create('category', { id: 'cat1', name: 'Just For Fun', slug: 'justforfun', icon: 'smile' }), - create('category', { id: 'cat2', name: 'Happyness & Values', slug: 'happyness-values', icon: 'heart-o' }), - create('category', { id: 'cat3', name: 'Health & Wellbeing', slug: 'health-wellbeing', icon: 'medkit' }), - create('category', { id: 'cat4', name: 'Environment & Nature', slug: 'environment-nature', icon: 'tree' }), - create('category', { id: 'cat5', name: 'Animal Protection', slug: 'animalprotection', icon: 'paw' }), - create('category', { id: 'cat6', name: 'Humanrights Justice', slug: 'humanrights-justice', icon: 'balance-scale' }), - create('category', { id: 'cat7', name: 'Education & Sciences', slug: 'education-sciences', icon: 'graduation-cap' }), - create('category', { id: 'cat8', name: 'Cooperation & Development', slug: 'cooperation-development', icon: 'users' }), - create('category', { id: 'cat9', name: 'Democracy & Politics', slug: 'democracy-politics', icon: 'university' }), - create('category', { id: 'cat10', name: 'Economy & Finances', slug: 'economy-finances', icon: 'money' }), - create('category', { id: 'cat11', name: 'Energy & Technology', slug: 'energy-technology', icon: 'flash' }), - create('category', { id: 'cat12', name: 'IT, Internet & Data Privacy', slug: 'it-internet-dataprivacy', icon: 'mouse-pointer' }), - create('category', { id: 'cat13', name: 'Art, Curlure & Sport', slug: 'art-culture-sport', icon: 'paint-brush' }), - create('category', { id: 'cat14', name: 'Freedom of Speech', slug: 'freedomofspeech', icon: 'bullhorn' }), - create('category', { id: 'cat15', name: 'Consumption & Sustainability', slug: 'consumption-sustainability', icon: 'shopping-cart' }), - create('category', { id: 'cat16', name: 'Global Peace & Nonviolence', slug: 'globalpeace-nonviolence', icon: 'angellist' }) + f.create('Category', { id: 'cat1', name: 'Just For Fun', slug: 'justforfun', icon: 'smile' }), + f.create('Category', { id: 'cat2', name: 'Happyness & Values', slug: 'happyness-values', icon: 'heart-o' }), + f.create('Category', { id: 'cat3', name: 'Health & Wellbeing', slug: 'health-wellbeing', icon: 'medkit' }), + f.create('Category', { id: 'cat4', name: 'Environment & Nature', slug: 'environment-nature', icon: 'tree' }), + f.create('Category', { id: 'cat5', name: 'Animal Protection', slug: 'animalprotection', icon: 'paw' }), + f.create('Category', { id: 'cat6', name: 'Humanrights Justice', slug: 'humanrights-justice', icon: 'balance-scale' }), + f.create('Category', { id: 'cat7', name: 'Education & Sciences', slug: 'education-sciences', icon: 'graduation-cap' }), + f.create('Category', { id: 'cat8', name: 'Cooperation & Development', slug: 'cooperation-development', icon: 'users' }), + f.create('Category', { id: 'cat9', name: 'Democracy & Politics', slug: 'democracy-politics', icon: 'university' }), + f.create('Category', { id: 'cat10', name: 'Economy & Finances', slug: 'economy-finances', icon: 'money' }), + f.create('Category', { id: 'cat11', name: 'Energy & Technology', slug: 'energy-technology', icon: 'flash' }), + f.create('Category', { id: 'cat12', name: 'IT, Internet & Data Privacy', slug: 'it-internet-dataprivacy', icon: 'mouse-pointer' }), + f.create('Category', { id: 'cat13', name: 'Art, Curlure & Sport', slug: 'art-culture-sport', icon: 'paint-brush' }), + f.create('Category', { id: 'cat14', name: 'Freedom of Speech', slug: 'freedomofspeech', icon: 'bullhorn' }), + f.create('Category', { id: 'cat15', name: 'Consumption & Sustainability', slug: 'consumption-sustainability', icon: 'shopping-cart' }), + f.create('Category', { id: 'cat16', name: 'Global Peace & Nonviolence', slug: 'globalpeace-nonviolence', icon: 'angellist' }) ]) await Promise.all([ - create('tag', { id: 't1', name: 'Umwelt' }), - create('tag', { id: 't2', name: 'Naturschutz' }), - create('tag', { id: 't3', name: 'Demokratie' }), - create('tag', { id: 't4', name: 'Freiheit' }) + f.create('Tag', { id: 't1', name: 'Umwelt' }), + f.create('Tag', { id: 't2', name: 'Naturschutz' }), + f.create('Tag', { id: 't3', name: 'Demokratie' }), + f.create('Tag', { id: 't4', name: 'Freiheit' }) ]) const [ asAdmin, asModerator, asUser, asTick, asTrick, asTrack ] = await Promise.all([ @@ -79,113 +80,113 @@ import Factory, { create, relate } from './factories' ]) await Promise.all([ - asAdmin.create('post', { id: 'p0' }), - asModerator.create('post', { id: 'p1' }), - asUser.create('post', { id: 'p2' }), - asTick.create('post', { id: 'p3' }), - asTrick.create('post', { id: 'p4' }), - asTrack.create('post', { id: 'p5' }), - asAdmin.create('post', { id: 'p6' }), - asModerator.create('post', { id: 'p7' }), - asUser.create('post', { id: 'p8' }), - asTick.create('post', { id: 'p9' }), - asTrick.create('post', { id: 'p10' }), - asTrack.create('post', { id: 'p11' }), - asAdmin.create('post', { id: 'p12' }), - asModerator.create('post', { id: 'p13' }), - asUser.create('post', { id: 'p14' }), - asTick.create('post', { id: 'p15' }) + asAdmin.create('Post', { id: 'p0' }), + asModerator.create('Post', { id: 'p1' }), + asUser.create('Post', { id: 'p2' }), + asTick.create('Post', { id: 'p3' }), + asTrick.create('Post', { id: 'p4' }), + asTrack.create('Post', { id: 'p5' }), + asAdmin.create('Post', { id: 'p6' }), + asModerator.create('Post', { id: 'p7' }), + asUser.create('Post', { id: 'p8' }), + asTick.create('Post', { id: 'p9' }), + asTrick.create('Post', { id: 'p10' }), + asTrack.create('Post', { id: 'p11' }), + asAdmin.create('Post', { id: 'p12' }), + asModerator.create('Post', { id: 'p13' }), + asUser.create('Post', { id: 'p14' }), + asTick.create('Post', { id: 'p15' }) ]) await Promise.all([ - relate('post', 'Categories', { from: 'p0', to: 'cat16' }), - relate('post', 'Categories', { from: 'p1', to: 'cat1' }), - relate('post', 'Categories', { from: 'p2', to: 'cat2' }), - relate('post', 'Categories', { from: 'p3', to: 'cat3' }), - relate('post', 'Categories', { from: 'p4', to: 'cat4' }), - relate('post', 'Categories', { from: 'p5', to: 'cat5' }), - relate('post', 'Categories', { from: 'p6', to: 'cat6' }), - relate('post', 'Categories', { from: 'p7', to: 'cat7' }), - relate('post', 'Categories', { from: 'p8', to: 'cat8' }), - relate('post', 'Categories', { from: 'p9', to: 'cat9' }), - relate('post', 'Categories', { from: 'p10', to: 'cat10' }), - relate('post', 'Categories', { from: 'p11', to: 'cat11' }), - relate('post', 'Categories', { from: 'p12', to: 'cat12' }), - relate('post', 'Categories', { from: 'p13', to: 'cat13' }), - relate('post', 'Categories', { from: 'p14', to: 'cat14' }), - relate('post', 'Categories', { from: 'p15', to: 'cat15' }), + f.relate('Post', 'Categories', { from: 'p0', to: 'cat16' }), + f.relate('Post', 'Categories', { from: 'p1', to: 'cat1' }), + f.relate('Post', 'Categories', { from: 'p2', to: 'cat2' }), + f.relate('Post', 'Categories', { from: 'p3', to: 'cat3' }), + f.relate('Post', 'Categories', { from: 'p4', to: 'cat4' }), + f.relate('Post', 'Categories', { from: 'p5', to: 'cat5' }), + f.relate('Post', 'Categories', { from: 'p6', to: 'cat6' }), + f.relate('Post', 'Categories', { from: 'p7', to: 'cat7' }), + f.relate('Post', 'Categories', { from: 'p8', to: 'cat8' }), + f.relate('Post', 'Categories', { from: 'p9', to: 'cat9' }), + f.relate('Post', 'Categories', { from: 'p10', to: 'cat10' }), + f.relate('Post', 'Categories', { from: 'p11', to: 'cat11' }), + f.relate('Post', 'Categories', { from: 'p12', to: 'cat12' }), + f.relate('Post', 'Categories', { from: 'p13', to: 'cat13' }), + f.relate('Post', 'Categories', { from: 'p14', to: 'cat14' }), + f.relate('Post', 'Categories', { from: 'p15', to: 'cat15' }), - relate('post', 'Tags', { from: 'p0', to: 't4' }), - relate('post', 'Tags', { from: 'p1', to: 't1' }), - relate('post', 'Tags', { from: 'p2', to: 't2' }), - relate('post', 'Tags', { from: 'p3', to: 't3' }), - relate('post', 'Tags', { from: 'p4', to: 't4' }), - relate('post', 'Tags', { from: 'p5', to: 't1' }), - relate('post', 'Tags', { from: 'p6', to: 't2' }), - relate('post', 'Tags', { from: 'p7', to: 't3' }), - relate('post', 'Tags', { from: 'p8', to: 't4' }), - relate('post', 'Tags', { from: 'p9', to: 't1' }), - relate('post', 'Tags', { from: 'p10', to: 't2' }), - relate('post', 'Tags', { from: 'p11', to: 't3' }), - relate('post', 'Tags', { from: 'p12', to: 't4' }), - relate('post', 'Tags', { from: 'p13', to: 't1' }), - relate('post', 'Tags', { from: 'p14', to: 't2' }), - relate('post', 'Tags', { from: 'p15', to: 't3' }) + f.relate('Post', 'Tags', { from: 'p0', to: 't4' }), + f.relate('Post', 'Tags', { from: 'p1', to: 't1' }), + f.relate('Post', 'Tags', { from: 'p2', to: 't2' }), + f.relate('Post', 'Tags', { from: 'p3', to: 't3' }), + f.relate('Post', 'Tags', { from: 'p4', to: 't4' }), + f.relate('Post', 'Tags', { from: 'p5', to: 't1' }), + f.relate('Post', 'Tags', { from: 'p6', to: 't2' }), + f.relate('Post', 'Tags', { from: 'p7', to: 't3' }), + f.relate('Post', 'Tags', { from: 'p8', to: 't4' }), + f.relate('Post', 'Tags', { from: 'p9', to: 't1' }), + f.relate('Post', 'Tags', { from: 'p10', to: 't2' }), + f.relate('Post', 'Tags', { from: 'p11', to: 't3' }), + f.relate('Post', 'Tags', { from: 'p12', to: 't4' }), + f.relate('Post', 'Tags', { from: 'p13', to: 't1' }), + f.relate('Post', 'Tags', { from: 'p14', to: 't2' }), + f.relate('Post', 'Tags', { from: 'p15', to: 't3' }) ]) await Promise.all([ - relate('user', 'Shouted', { from: 'u1', to: 'p2' }), - relate('user', 'Shouted', { from: 'u1', to: 'p3' }), - relate('user', 'Shouted', { from: 'u2', to: 'p1' }), - relate('user', 'Shouted', { from: 'u3', to: 'p1' }), - relate('user', 'Shouted', { from: 'u3', to: 'p4' }), - relate('user', 'Shouted', { from: 'u4', to: 'p1' }) + f.relate('User', 'Shouted', { from: 'u1', to: 'p2' }), + f.relate('User', 'Shouted', { from: 'u1', to: 'p3' }), + f.relate('User', 'Shouted', { from: 'u2', to: 'p1' }), + f.relate('User', 'Shouted', { from: 'u3', to: 'p1' }), + f.relate('User', 'Shouted', { from: 'u3', to: 'p4' }), + f.relate('User', 'Shouted', { from: 'u4', to: 'p1' }) ]) await Promise.all([ - create('comment', { id: 'c1' }), - create('comment', { id: 'c2' }), - create('comment', { id: 'c3' }), - create('comment', { id: 'c4' }), - create('comment', { id: 'c5' }), - create('comment', { id: 'c6' }), - create('comment', { id: 'c7' }) + f.create('Comment', { id: 'c1' }), + f.create('Comment', { id: 'c2' }), + f.create('Comment', { id: 'c3' }), + f.create('Comment', { id: 'c4' }), + f.create('Comment', { id: 'c5' }), + f.create('Comment', { id: 'c6' }), + f.create('Comment', { id: 'c7' }) ]) await Promise.all([ - relate('comment', 'Author', { from: 'u3', to: 'c1' }), - relate('comment', 'Post', { from: 'c1', to: 'p1' }), - relate('comment', 'Author', { from: 'u1', to: 'c2' }), - relate('comment', 'Post', { from: 'c2', to: 'p1' }), - relate('comment', 'Author', { from: 'u1', to: 'c3' }), - relate('comment', 'Post', { from: 'c3', to: 'p3' }), - relate('comment', 'Author', { from: 'u4', to: 'c4' }), - relate('comment', 'Post', { from: 'c4', to: 'p2' }), - relate('comment', 'Author', { from: 'u4', to: 'c5' }), - relate('comment', 'Post', { from: 'c5', to: 'p3' }), - relate('comment', 'Author', { from: 'u3', to: 'c6' }), - relate('comment', 'Post', { from: 'c6', to: 'p4' }), - relate('comment', 'Author', { from: 'u2', to: 'c7' }), - relate('comment', 'Post', { from: 'c7', to: 'p2' }) + f.relate('Comment', 'Author', { from: 'u3', to: 'c1' }), + f.relate('Comment', 'Post', { from: 'c1', to: 'p1' }), + f.relate('Comment', 'Author', { from: 'u1', to: 'c2' }), + f.relate('Comment', 'Post', { from: 'c2', to: 'p1' }), + f.relate('Comment', 'Author', { from: 'u1', to: 'c3' }), + f.relate('Comment', 'Post', { from: 'c3', to: 'p3' }), + f.relate('Comment', 'Author', { from: 'u4', to: 'c4' }), + f.relate('Comment', 'Post', { from: 'c4', to: 'p2' }), + f.relate('Comment', 'Author', { from: 'u4', to: 'c5' }), + f.relate('Comment', 'Post', { from: 'c5', to: 'p3' }), + f.relate('Comment', 'Author', { from: 'u3', to: 'c6' }), + f.relate('Comment', 'Post', { from: 'c6', to: 'p4' }), + f.relate('Comment', 'Author', { from: 'u2', to: 'c7' }), + f.relate('Comment', 'Post', { from: 'c7', to: 'p2' }) ]) await Promise.all([ - asTick.create('report', { description: 'I don\'t like this comment', resource: { id: 'c1', type: 'comment' } }), - asTrick.create('report', { description: 'I don\'t like this post', resource: { id: 'p1', type: 'contribution' } }), - asTrack.create('report', { description: 'I don\'t like this user', resource: { id: 'u1', type: 'user' } }) + asTick.create('Report', { description: 'I don\'t like this comment', resource: { id: 'c1', type: 'comment' } }), + asTrick.create('Report', { description: 'I don\'t like this post', resource: { id: 'p1', type: 'contribution' } }), + asTrack.create('Report', { description: 'I don\'t like this user', resource: { id: 'u1', type: 'user' } }) ]) await Promise.all([ - create('organization', { id: 'o1', name: 'Democracy Deutschland', description: 'Description for democracy-deutschland.' }), - create('organization', { id: 'o2', name: 'Human-Connection', description: 'Description for human-connection.' }), - create('organization', { id: 'o3', name: 'Pro Veg', description: 'Description for pro-veg.' }), - create('organization', { id: 'o4', name: 'Greenpeace', description: 'Description for greenpeace.' }) + f.create('Organization', { id: 'o1', name: 'Democracy Deutschland', description: 'Description for democracy-deutschland.' }), + f.create('Organization', { id: 'o2', name: 'Human-Connection', description: 'Description for human-connection.' }), + f.create('Organization', { id: 'o3', name: 'Pro Veg', description: 'Description for pro-veg.' }), + f.create('Organization', { id: 'o4', name: 'Greenpeace', description: 'Description for greenpeace.' }) ]) await Promise.all([ - relate('organization', 'CreatedBy', { from: 'u1', to: 'o1' }), - relate('organization', 'CreatedBy', { from: 'u1', to: 'o2' }), - relate('organization', 'OwnedBy', { from: 'u2', to: 'o2' }), - relate('organization', 'OwnedBy', { from: 'u2', to: 'o3' }) + f.relate('Organization', 'CreatedBy', { from: 'u1', to: 'o1' }), + f.relate('Organization', 'CreatedBy', { from: 'u1', to: 'o2' }), + f.relate('Organization', 'OwnedBy', { from: 'u2', to: 'o2' }), + f.relate('Organization', 'OwnedBy', { from: 'u2', to: 'o3' }) ]) /* eslint-disable-next-line no-console */ console.log('Seeded Data...')