let bcrypt = require('bcryptjs')
let randomColor = require('randomcolor')
var passportLocalSequelize = require('passport-local-sequelize');
let pagination = require('../lib/pagination.js')
const Errors = require('../lib/errors.js')
var crypto = require("crypto");
var cryptoRandomString = require("crypto-random-string");
module.exports = (sequelize, DataTypes) => {
    let Inventory = sequelize.define('Inventory', {
            purchasePrice: {
                type: DataTypes.BIGINT,
                validate: {
                    isNumeric: {
                        args: true,
                        msg: 'The purchase price of your Inventory Item needs to be a numeric value, numbers only.'
                    }
                }
            },
            isReselling: {
                type: DataTypes.BOOLEAN,
                default: 0,
                defaultValue: 0,
                validate: {
                    isBoolean: {
                        args: true,
                        msg: 'You can only set this as a true or false value.'
                    }
                }
            },
            isResellingPrice: {
                type: DataTypes.BIGINT,
                validate: {
                    isNumeric: {
                        args: true,
                        msg: 'The quantity of your Marketplace Item Resell needs to be a numeric value, numbers only.'
                    }
                }
            },
            ItemId: {
                type: DataTypes.BIGINT
            },
            UserId: {
                type: DataTypes.BIGINT
            },
            createdAt: {
                type: DataTypes.DATE
            },
            updatedAt: {
                type: DataTypes.DATE
            },
            boughtFrom: {
                type: DataTypes.BIGINT,
                validate: {
                    isNumeric: {
                        args: true,
                        msg: 'The original owner user ID of your Marketplace Item needs to be a numeric value, numbers only.'
                    }
                }
            }
        })
    Inventory.associate = function (models) {
        Inventory.belongsTo(models.User, {through: 'User'})
        Inventory.belongsTo(models.Item)
    }
    return Inventory
}
