# All files / src/model alerts.coffee

100% Statements 6/6
100% Branches 0/0
100% Functions 0/0
100% Lines 6/6

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    181x
    1x
    1x
    1x

    1x

    1x
     mongoose = require "mongoose"
    server = require "../server"
    connectionDefault = server.connectionDefault
    Schema = mongoose.Schema

    # A collection for keeping a day-long log of any alerts that got sent out to users
    # It is used for the user max-alert policies
    AlertSchema = new Schema
      "user":         type: String, required: true
      "method":       type: String, required: true
      "timestamp":    type: Date, required: true, default: Date.now, expires: '1d'
      "channelID":    type: String, required: true
      "condition":    type: String, required: true
      "status":       type: String, required: true
      "alertStatus":  type: String, required: true, enum: ["Failed", "Completed"]

    exports.Alert = connectionDefault.model 'Alert', AlertSchema