3 module.exports = function(sequelize, DataTypes) {
5 var CustomReport = sequelize.define('CustomReport', {
6 name: DataTypes.STRING,
7 description: DataTypes.STRING,
8 parent: DataTypes.STRING,
9 table: DataTypes.STRING,
10 conditions: DataTypes.TEXT
13 tableName: 'analytics_custom_reports',
14 associate: function(models) {
15 CustomReport.hasMany(models.ReportField, {
20 CustomReport.addScope('fields', {
22 model: models.ReportField,
25 attributes: ['field', 'alias', 'function', 'groupBy', 'orderBy', 'MetricId', 'format', 'custom'],
29 CustomReport.addScope('exportFields', function(query) {
32 model: models.ReportField,
35 attributes: ['field', 'alias', 'function', 'groupBy', 'orderBy', 'MetricId', 'format', 'custom'],
38 attributes: ['description', 'metric', 'name', 'table'],
41 model: models.ReportField,
43 attributes: ['field', 'alias', 'function', 'groupBy', 'orderBy', 'format'],