156 lines
1.9 KiB
JavaScript
156 lines
1.9 KiB
JavaScript
const config = require('../../config');
|
|
const providers = config.providers;
|
|
const crypto = require('crypto');
|
|
const bcrypt = require('bcrypt');
|
|
const moment = require('moment');
|
|
|
|
module.exports = function(sequelize, DataTypes) {
|
|
const deposits = sequelize.define(
|
|
'deposits',
|
|
{
|
|
id: {
|
|
type: DataTypes.UUID,
|
|
defaultValue: DataTypes.UUIDV4,
|
|
primaryKey: true,
|
|
},
|
|
|
|
currency: {
|
|
type: DataTypes.ENUM,
|
|
|
|
|
|
|
|
values: [
|
|
|
|
"USDT",
|
|
|
|
|
|
"TRX",
|
|
|
|
|
|
"BNB"
|
|
|
|
],
|
|
|
|
},
|
|
|
|
amount: {
|
|
type: DataTypes.DECIMAL,
|
|
|
|
|
|
|
|
},
|
|
|
|
tx_hash: {
|
|
type: DataTypes.TEXT,
|
|
|
|
|
|
|
|
},
|
|
|
|
status: {
|
|
type: DataTypes.ENUM,
|
|
|
|
|
|
|
|
values: [
|
|
|
|
"pending",
|
|
|
|
|
|
"confirmed",
|
|
|
|
|
|
"rejected"
|
|
|
|
],
|
|
|
|
},
|
|
|
|
received_on: {
|
|
type: DataTypes.DATE,
|
|
|
|
|
|
|
|
},
|
|
|
|
confirmed_on: {
|
|
type: DataTypes.DATE,
|
|
|
|
|
|
|
|
},
|
|
|
|
importHash: {
|
|
type: DataTypes.STRING(255),
|
|
allowNull: true,
|
|
unique: true,
|
|
},
|
|
},
|
|
{
|
|
timestamps: true,
|
|
paranoid: true,
|
|
freezeTableName: true,
|
|
},
|
|
);
|
|
|
|
deposits.associate = (db) => {
|
|
|
|
|
|
/// loop through entities and it's fields, and if ref === current e[name] and create relation has many on parent entity
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//end loop
|
|
|
|
|
|
|
|
db.deposits.belongsTo(db.wallets, {
|
|
as: 'wallet',
|
|
foreignKey: {
|
|
name: 'walletId',
|
|
},
|
|
constraints: false,
|
|
});
|
|
|
|
|
|
|
|
db.deposits.hasMany(db.file, {
|
|
as: 'receipts',
|
|
foreignKey: 'belongsToId',
|
|
constraints: false,
|
|
scope: {
|
|
belongsTo: db.deposits.getTableName(),
|
|
belongsToColumn: 'receipts',
|
|
},
|
|
});
|
|
|
|
|
|
db.deposits.belongsTo(db.users, {
|
|
as: 'createdBy',
|
|
});
|
|
|
|
db.deposits.belongsTo(db.users, {
|
|
as: 'updatedBy',
|
|
});
|
|
};
|
|
|
|
|
|
|
|
return deposits;
|
|
};
|
|
|
|
|