minor with new models

This commit is contained in:
lesion 2023-01-10 18:16:11 +01:00
parent cd5c4fae29
commit c3741238fc
No known key found for this signature in database
GPG key ID: 352918250B012177
8 changed files with 14 additions and 23 deletions

View file

@ -33,7 +33,7 @@ async function modify (args) {
async function create (args) {
await _initializeDB()
const User = require('../api/models/user')
const { User } = require('../api/models/models')
const user = await User.create({
email: args.email,
is_active: true,
@ -46,7 +46,7 @@ async function create (args) {
async function remove (args) {
await _initializeDB()
const User = require('../api/models/user')
const { User } = require('../api/models/models')
const user = await User.findOne({
where: { email: args.email }
})
@ -58,7 +58,7 @@ async function remove (args) {
async function list () {
await _initializeDB()
const User = require('../api/models/user')
const { User } = require('../api/models/models')
const users = await User.findAll()
console.log()
users.forEach(u => console.log(`${u.id}\tadmin: ${u.is_admin}\tenabled: ${u.is_active}\temail: ${u.email}`))

View file

@ -1,4 +1,4 @@
const Event = require('../api/models/event')
const { Event } = require('../api/models/models')
const config = require('../config')
const log = require('../log')

View file

@ -2,10 +2,8 @@ const express = require('express')
const router = express.Router()
const cors = require('cors')
const Users = require('./users')
const Event = require('../api/models/event')
const User = require('../api/models/user')
const Tag = require('../api/models/tag')
const Place = require('../api/models/place')
const { Event, User, Tag, Place } = require('../api/models/models')
const settingsController = require('../api/controller/settings')
const Helpers = require('./helpers')

View file

@ -1,6 +1,4 @@
const Event = require('../api/models/event')
const Resource = require('../api/models/resource')
const APUser = require('../api/models/ap_user')
const { Event, Resource, APUser } = require('../api/models/models')
const log = require('../log')
const helpers = require('../helpers')

View file

@ -1,7 +1,5 @@
const Event = require('../api/models/event')
const Place = require('../api/models/place')
const APUser = require('../api/models/ap_user')
const Tag = require('../api/models/tag')
const { Event, Place, APUser, Tag } = require('../api/models/models')
const escape = require('lodash/escape')
const config = require('../config')
const log = require('../log')

View file

@ -1,8 +1,6 @@
const express = require('express')
const router = express.Router()
const Event = require('../api/models/event')
const Resource = require('../api/models/resource')
const User = require('../api/models/user')
const { Event, Resource, User } = require('../api/models/models')
const cors = require('cors')
const settingsController = require('../api/controller/settings')

View file

@ -1,5 +1,4 @@
const Place = require('../api/models/place')
const Event = require('../api/models/event')
const { Event, Place } = require('../api/models/models')
const Sequelize = require('sequelize')
const log = require('../log')

View file

@ -1,5 +1,5 @@
const Tag = require('../api/models/tag')
const Event = require('../api/models/event')
const { Event, Tag } = require('../api/models/models')
const Sequelize = require('sequelize')
const log = require('../log')
@ -13,7 +13,7 @@ module.exports = {
})
if (!tags.length) { return }
log.info(`Remove ${tags.length} unrelated tags`)
log.info(`Remove ${tags.length} orphan tags (${tags.join(', ')})`)
await Tag.destroy({
where: { tag: { [Sequelize.Op.in]: tags.map(p => p.tag) } }