{
    "fields": {
        "name": {
            "type": "varchar",
            "required": true,
            "trim": true
        },
        "status": {
            "type": "enum",
            "options": ["Planning", "Active", "Inactive", "Complete"],
            "default": "Planning"
        },
        "type": {
            "type": "enum",
            "options": ["Email", "Newsletter", "Web", "Television", "Radio", "Mail"],
            "default": "Email"
        },
        "startDate": {
            "type": "date"
        },
        "endDate": {
            "type": "date"
        },
        "description": {
            "type": "text"
        },
        "createdAt": {
            "type": "datetime",
            "readOnly": true
        },
        "modifiedAt": {
            "type": "datetime",
            "readOnly": true
        },
        "createdBy": {
            "type": "link",
            "readOnly": true,
            "view": "views/fields/user"
        },
        "modifiedBy": {
            "type": "link",
            "readOnly": true,
            "view": "views/fields/user"
        },
        "assignedUser": {
            "type": "link",
            "view": "views/fields/assigned-user"
        },
        "teams": {
            "type": "linkMultiple",
            "view": "views/fields/teams"
        },
        "targetLists": {
            "type": "linkMultiple",
            "tooltip": true
        },
        "excludingTargetLists": {
            "type": "linkMultiple",
            "tooltip": true
        },
        "sentCount": {
            "type": "int",
            "notStorable": true,
            "directAccessDisabled": true,
            "readOnly": true,
            "disabled": true
        },
        "openedCount": {
            "view": "crm:views/campaign/fields/int-with-percentage",
            "type": "int",
            "notStorable": true,
            "directAccessDisabled": true,
            "readOnly": true,
            "disabled": true
        },
        "clickedCount": {
            "view": "crm:views/campaign/fields/int-with-percentage",
            "type": "int",
            "notStorable": true,
            "directAccessDisabled": true,
            "readOnly": true,
            "disabled": true
        },
        "optedInCount": {
            "type": "int",
            "notStorable": true,
            "directAccessDisabled": true,
            "readOnly": true,
            "disabled": true
        },
        "optedOutCount": {
            "view": "crm:views/campaign/fields/int-with-percentage",
            "type": "int",
            "notStorable": true,
            "directAccessDisabled": true,
            "readOnly": true,
            "disabled": true
        },
        "bouncedCount": {
            "view": "crm:views/campaign/fields/int-with-percentage",
            "type": "int",
            "notStorable": true,
            "directAccessDisabled": true,
            "readOnly": true,
            "disabled": true
        },
        "hardBouncedCount": {
            "type": "int",
            "notStorable": true,
            "directAccessDisabled": true,
            "readOnly": true,
            "disabled": true
        },
        "softBouncedCount": {
            "type": "int",
            "notStorable": true,
            "directAccessDisabled": true,
            "readOnly": true,
            "disabled": true
        },
        "leadCreatedCount": {
            "type": "int",
            "notStorable": true,
            "directAccessDisabled": true,
            "readOnly": true,
            "disabled": true
        },
        "openedPercentage": {
            "type": "int",
            "notStorable": true,
            "directAccessDisabled": true,
            "readOnly": true,
            "disabled": true
        },
        "clickedPercentage": {
            "type": "int",
            "notStorable": true,
            "directAccessDisabled": true,
            "readOnly": true,
            "disabled": true
        },
        "optedOutPercentage": {
            "type": "int",
            "notStorable": true,
            "directAccessDisabled": true,
            "readOnly": true,
            "disabled": true
        },
        "bouncedPercentage": {
            "type": "int",
            "notStorable": true,
            "directAccessDisabled": true,
            "readOnly": true,
            "disabled": true
        },
        "revenue": {
            "type": "currency",
            "notStorable": true,
            "directAccessDisabled": true,
            "readOnly": true,
            "disabled": true
        },
        "budget": {
            "type": "currency"
        },
        "contactsTemplate": {
            "type": "link",
            "view": "crm:views/campaign/fields/template",
            "targetEntityType": "Contact"
        },
        "leadsTemplate": {
            "type": "link",
            "view": "crm:views/campaign/fields/template",
            "targetEntityType": "Lead"
        },
        "accountsTemplate": {
            "type": "link",
            "view": "crm:views/campaign/fields/template",
            "targetEntityType": "Account"
        },
        "usersTemplate": {
            "type": "link",
            "view": "crm:views/campaign/fields/template",
            "targetEntityType": "User"
        },
        "mailMergeOnlyWithAddress": {
            "type": "bool",
            "default": true
        }
    },
    "links": {
        "createdBy": {
            "type": "belongsTo",
            "entity": "User"
        },
        "modifiedBy": {
            "type": "belongsTo",
            "entity": "User"
        },
        "assignedUser": {
            "type": "belongsTo",
            "entity": "User"
        },
        "teams": {
            "type": "hasMany",
            "entity": "Team",
            "relationName": "entityTeam",
            "layoutRelationshipsDisabled": true
        },
        "targetLists": {
            "type": "hasMany",
            "entity": "TargetList",
            "foreign": "campaigns"
        },
        "excludingTargetLists": {
            "type": "hasMany",
            "entity": "TargetList",
            "foreign": "campaignsExcluding",
            "relationName": "campaignTargetListExcluding"
        },
        "accounts": {
            "type": "hasMany",
            "entity": "Account",
            "foreign": "campaign"
        },
        "contacts": {
            "type": "hasMany",
            "entity": "Contact",
            "foreign": "campaign"
        },
        "leads": {
            "type": "hasMany",
            "entity": "Lead",
            "foreign": "campaign"
        },
        "opportunities": {
            "type": "hasMany",
            "entity": "Opportunity",
            "foreign": "campaign"
        },
        "campaignLogRecords": {
            "type": "hasMany",
            "entity": "CampaignLogRecord",
            "foreign": "campaign"
        },
        "trackingUrls": {
            "type": "hasMany",
            "entity": "CampaignTrackingUrl",
            "foreign": "campaign"
        },
        "massEmails": {
            "type": "hasMany",
            "entity": "MassEmail",
            "foreign": "campaign",
            "layoutRelationshipsDisabled": true
        },
        "contactsTemplate": {
            "type": "belongsTo",
            "entity": "Template",
            "noJoin": true
        },
        "leadsTemplate": {
            "type": "belongsTo",
            "entity": "Template",
            "noJoin": true
        },
        "accountsTemplate": {
            "type": "belongsTo",
            "entity": "Template",
            "noJoin": true
        },
        "usersTemplate": {
            "type": "belongsTo",
            "entity": "Template",
            "noJoin": true
        }
    },
    "collection": {
        "orderBy": "createdAt",
        "order": "desc"
    },
    "indexes": {
        "createdAt": {
            "columns": ["createdAt", "deleted"]
        }
    }
}
