moonmail

Diff between MoonMail / moonmail-models


Is there a reason we can find this code in moonmail-models:

userId: _joi2.default.string().required(),
body: _joi2.default.string().required(),
subject: _joi2.default.string().required(),
name: _joi2.default.string().required(),
id: _joi2.default.string().required(),
senderId: _joi2.default.string(),
listIds: _joi2.default.array(),
sentAt: _joi2.default.number(),
createdAt: _joi2.default.number(),
scheduledAt: _joi2.default.number(),
status: _joi2.default.string(),
isUpToDate: _joi2.default.boolean(),
template: _joi2.default.string()

But there is no equivalent in MoonMail's s-resources-cf.json:

"CampaignsTable": {
  "Type": "AWS::DynamoDB::Table",
  "DeletionPolicy": "Retain",
  "Properties": {
    "AttributeDefinitions": [
      {
        "AttributeName": "id",
        "AttributeType": "S"
      },
      {
        "AttributeName": "userId",
        "AttributeType": "S"
      },
      {
        "AttributeName": "sentAt",
        "AttributeType": "N"
      },
      {
        "AttributeName": "scheduledAt",
        "AttributeType": "N"
      }
    ]
    }
}

Where is the body and subject stored in the DynamoDB?


Solution

  • To find the code to store the campaign data check out this file https://github.com/microapps/moonmail-models/blob/master/src/models/campaign.js

    "Is there a reason we can find this code in moonmail-models?"

    Yes it implies before saving the data it will validate the data you pass to dynamodb with the schema of the table

    " this._validateSchema(schema, campaign) && campaign.status === 'draft'; "

    The data from the api controllers is passed to moonmail models and for each table there is a file in

    https://github.com/microapps/moonmail-models/blob/master/src folder those files extends Model.js which handles URD - Update, Read and Delete operations on DynamoDB