Skip to content
Snippets Groups Projects
Commit cf7e4b13 authored by Giannis Kopanas's avatar Giannis Kopanas Committed by Alexandros Georgantas
Browse files

fix(seed): fix global teams script

parent d3cd8295
No related branches found
No related tags found
2 merge requests!15File upload,!11Move navigation to monorepo
#!/usr/bin/env node #!/usr/bin/env node
const logger = require('@pubsweet/logger') 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 makeTeam = async type => {
const names = { const names = {
...@@ -12,14 +16,17 @@ const makeTeam = async type => { ...@@ -12,14 +16,17 @@ const makeTeam = async type => {
logger.info(`Create ${names[type]} team`) logger.info(`Create ${names[type]} team`)
const team = new Team({ await Team.query().upsertGraphAndFetch(
global: true, {
members: [], global: true,
name: names[type], members: [],
teamType: type, name: names[type],
}) role: type,
},
await team.save() { relate: true },
)
// await team.save()
logger.info(`${names[type]} team successfully created`) logger.info(`${names[type]} team successfully created`)
} }
...@@ -30,9 +37,7 @@ const seed = async () => { ...@@ -30,9 +37,7 @@ const seed = async () => {
try { try {
const teams = await Team.findByField({ global: true }) const teams = await Team.findByField({ global: true })
const productionEditorTeam = teams.find( const productionEditorTeam = teams.find(t => t.role === 'productionEditor')
t => t.teamType === 'productionEditor',
)
if (productionEditorTeam) { if (productionEditorTeam) {
logger.info('All global teams found, exiting...') logger.info('All global teams found, exiting...')
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment