const mongoose = require("mongoose");

const dbConnection = require("../config/config.js");
mongoose.connection = dbConnection;
// require clak module to give colors to console text.
var chalk = require("chalk");

// Define colors for db messages on cosole.

const Schema = mongoose.Schema;

const messageSchema = new mongoose.Schema(
  {
    body: String,
    numSegments: String,
    direction: String,
    from: String,
    to: String,
    dateUpdated: Date,
    price: String,
    errorMessage: String,
    uri: String,
    accountSid: String,
    numMedia: String,
    status: String,
    messagingServiceSid: String,
    sid: String,
    dateSent: Date,
    dateCreated: Date,
    errorCode: String,
    priceUnit: String,
    apiVersion: String,
    subresourceUris: {
      media: String,
    },
  },
  { versionKey: false }
);

module.exports = mongoose.model("Message", messageSchema);
