OurBigBook
web/bin/make-admin
#!/usr/bin/env node

// https://docs.ourbigbook.com/ourbigbook-web-admin

const path = require('path')

const commander = require('commander')

const models = require('../models')

// CLI arguments
const program = commander.program
program.allowExcessArguments(false)
program.option('-f, --false', 'remove admin instead of giving it')
program.argument('<username>', 'username')
program.parse(process.argv);
const opts = program.opts()
const [username] = program.processedArgs

// main
const sequelize = models.getSequelize(path.dirname(__dirname));
(async () => {
await sequelize.models.User.update(
  {
    admin: !opts.false
  },
  {
    where: {
      username,
    }
  }
)
})().finally(() => { return sequelize.close() });