let express = require('express')
let router = express.Router()
const auth = require('../lib/auth')

const Errors = require('../lib/errors')
let pagination = require('../lib/pagination')
let { Ban, Item, Inventory, ItemCategory, User, sequelize, Sequelize } = require('../models')

router.get('/', auth, async(req, res, next) => {
    try {
        let queryObj = {
            where: {UserId: req.userData.UserId},
            include: { model: Item, include: { model: User, attributes: ['username', 'createdAt', 'id', 'color', 'picture', 'locked', 'admin', 'booster', 'executive', 'bot'] } }
        }
        let transaction = await Inventory.findAll(queryObj)
        if(!transaction) {
            res.status(200)
            res.json({success: false})
        }
        res.json(transaction)
    } catch (e) { next(e) }
})
module.exports = router
