Skip to content

Instantly share code, notes, and snippets.

@Rowadz
Created March 29, 2019 14:07
Show Gist options
  • Select an option

  • Save Rowadz/1cb84aafe76060fc6632062d06eb9b78 to your computer and use it in GitHub Desktop.

Select an option

Save Rowadz/1cb84aafe76060fc6632062d06eb9b78 to your computer and use it in GitHub Desktop.
const Sequelize = require('sequelize');
const DataTypes = Sequelize.DataTypes;
module.exports = function (app) {
const sequelizeClient = app.get('sequelizeClient');
const uploads = sequelizeClient.define('uploads', {
description: {
type: DataTypes.TEXT,
allowNull: false
},
orignalName: {
type: DataTypes.STRING,
allowNull: false
},
newNameWithPath: {
type: DataTypes.STRING,
allowNull: false
}
}, {
hooks: {
beforeCount(options) {
options.raw = true;
}
}
});
uploads.associate = function (models) {
const {
users
} = models;
uploads.belongsTo(users);
};
return uploads;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment