working on some ideas for instance controller
This commit is contained in:
parent
c0fd2f575d
commit
502215447f
1 changed files with 30 additions and 4 deletions
|
@ -1,14 +1,40 @@
|
|||
const { ap_user: APUser, instance: Instance, resource: Resource } = require('../models')
|
||||
const {
|
||||
ap_user: APUser,
|
||||
instance: Instance,
|
||||
resource: Resource
|
||||
// event: Event
|
||||
} = require('../models')
|
||||
// const { Op } = require('sequelize')
|
||||
|
||||
const instancesController = {
|
||||
async getAll (req, res) {
|
||||
const instances = await Instance.findAll()
|
||||
|
||||
const instances = await Instance.findAll({ raw: true })
|
||||
return res.json(instances)
|
||||
},
|
||||
|
||||
// async getUsedInstance (req, res) {
|
||||
// // const ap_users = await APUser.findAll({
|
||||
// // attributes: ['ap_id', 'blocked', 'instanceDomain'],
|
||||
// // where: { [Op.or]: [{ follower: true }, { blocked: true }] },
|
||||
// // include: [
|
||||
// // { model: Resource, attributes: ['id', 'eventId'], include: [{ model: Event, attributes: ['title'] }] },
|
||||
// // { model: Instance, attributes: ['blocked', 'name', 'domain'] }],
|
||||
// // nest: true,
|
||||
// // raw: true
|
||||
// // })
|
||||
// const instances = await Instance.findAll({
|
||||
// include: [
|
||||
// { model: APUser, where: { [Op.or]: [{ follower: true }, { blocked: true }] }, attributes: [] }
|
||||
// ],
|
||||
// attributes: ['domain', 'name', 'blocked'],
|
||||
// raw: true
|
||||
// })
|
||||
// console.error(instances)
|
||||
// res.json(instances)
|
||||
// },
|
||||
|
||||
/**
|
||||
* get instance users
|
||||
* get instance's users
|
||||
*/
|
||||
async get (req, res) {
|
||||
const ap_users = await APUser.findAll({ where: { instanceDomain: req.params.instance_domain }, include: [Resource] })
|
||||
|
|
Loading…
Reference in a new issue