lib/Attribute.js
function createAttrDefFromDynamo (dynamoAttribute) {
  let dynamoType;
  const attrDef = {
    'type': module.exports.lookupType(dynamoAttribute)
  };
  if (attrDef.type === Object) {
    attrDef.type = 'map';
    for (dynamoType in dynamoAttribute) {
      attrDef.map = {};
      for (const subAttrName in dynamoAttribute[dynamoType]) {
        attrDef.map[subAttrName] = createAttrDefFromDynamo(dynamoAttribute[dynamoType][subAttrName]);
      }
    }
  } else if (attrDef.type === Array) {
    attrDef.type = 'list';
    for (dynamoType in dynamoAttribute) {
      attrDef.list = dynamoAttribute[dynamoType].map(createAttrDefFromDynamo);
    }
  }
  return attrDef;
}
function createAttrDefFromDynamo (dynamoAttribute) {
  let dynamoType;
  const attrDef = {
    'type': module.exports.lookupType(dynamoAttribute)
  };
  if (attrDef.type === Object) {
    attrDef.type = 'map';
    for (dynamoType in dynamoAttribute) {
      attrDef.map = {};
      for (const subAttrName in dynamoAttribute[dynamoType]) {
        attrDef.map[subAttrName] = createAttrDefFromDynamo(dynamoAttribute[dynamoType][subAttrName]);
      }
    }
  } else if (attrDef.type === Array) {
    attrDef.type = 'list';
    for (dynamoType in dynamoAttribute) {
      attrDef.list = dynamoAttribute[dynamoType].map(createAttrDefFromDynamo);
    }
  }
  return attrDef;
}
/*
Converts DynamoDB document types (Map and List) to dynamoose
attribute definition map and ist types

For example, DynamoDB value:
{
M: {
subAttr1: { S: '' },
subAttr2: { N: '' },
}
}

to
{
type: 'map',
map: {
subAttr1: { type: String },
subAttr1: { type: Number },
},
}