diff --git a/scripts/seedGlobalTeams.js b/scripts/seedGlobalTeams.js index ced7a87ecaf8e554d8b8873a13dece254bbeee12..e94aca935b0272f66810cdd70d2cb17b77ea0a5e 100644 --- a/scripts/seedGlobalTeams.js +++ b/scripts/seedGlobalTeams.js @@ -1,9 +1,13 @@ #!/usr/bin/env node const logger = require('@pubsweet/logger') -const { model } = require('@pubsweet/model-team') +const { + editoriaDataModel: { + models: { Team }, + }, +} = require('editoria-data-model') -const Team = model +console.log(Team) const makeTeam = async type => { const names = { @@ -12,14 +16,17 @@ const makeTeam = async type => { logger.info(`Create ${names[type]} team`) - const team = new Team({ - global: true, - members: [], - name: names[type], - teamType: type, - }) - - await team.save() + await Team.query().upsertGraphAndFetch( + { + global: true, + members: [], + name: names[type], + role: type, + }, + { relate: true }, + ) + + // await team.save() logger.info(`${names[type]} team successfully created`) } @@ -30,9 +37,7 @@ const seed = async () => { try { const teams = await Team.findByField({ global: true }) - const productionEditorTeam = teams.find( - t => t.teamType === 'productionEditor', - ) + const productionEditorTeam = teams.find(t => t.role === 'productionEditor') if (productionEditorTeam) { logger.info('All global teams found, exiting...')