forked from kaverti/website
Could break purchases, rollback if needed
This commit is contained in:
parent
c2d1857093
commit
e94a89b160
|
@ -7,58 +7,61 @@ 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.'
|
||||
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.'
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
isReselling: {
|
||||
type: DataTypes.BOOLEAN,
|
||||
default: 0,
|
||||
defaultValue: 0,
|
||||
validate: {
|
||||
isBoolean: {
|
||||
args: true,
|
||||
msg: 'You can only set this as a true or false value.'
|
||||
}
|
||||
}, {
|
||||
associate (models) {
|
||||
Inventory.belongsTo(models.User)
|
||||
Inventory.belongsTo(models.Item, { as: 'User'})
|
||||
}
|
||||
},
|
||||
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
|
||||
},
|
||||
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.'
|
||||
}
|
||||
}
|
||||
}
|
||||
}, {
|
||||
associate (models) {
|
||||
Inventory.belongsTo(models.User)
|
||||
Inventory.belongsTo(models.Item)
|
||||
}
|
||||
}
|
||||
)
|
||||
return Inventory
|
||||
|
|
Loading…
Reference in New Issue