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
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...')
......
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