Example #1
0
    attributes = Utils._.mapValues(attributes, function(attribute, name) {
      if (!Utils._.isPlainObject(attribute)) {
        attribute = { type: attribute, allowNull: true };
      }

      attribute.type = self.sequelize.normalizeDataType(attribute.type);

      if (attribute.hasOwnProperty('defaultValue')) {
        if (typeof attribute.defaultValue === "function" && (
            attribute.defaultValue === DataTypes.NOW ||
            attribute.defaultValue === DataTypes.UUIDV4 ||
            attribute.defaultValue === DataTypes.UUIDV4 
        )) {
          attribute.defaultValue = new attribute.defaultValue();
        }
      }

      if (attribute.type instanceof DataTypes.ENUM) {
        // The ENUM is a special case where the type is an object containing the values
        attribute.values = attribute.values || attribute.type.values || [];

        if (!attribute.values.length) {
          throw new Error('Values for ENUM haven\'t been defined.');
        }
      }

      return attribute;
    });
    attributes = Utils._.mapValues(attributes, function(attribute, name) {
      if (!Utils._.isPlainObject(attribute)) {
        attribute = { type: attribute, allowNull: true };
      }

      return attribute;
    });
Example #3
0
 indexFields = Utils._.map(value.fields, function (field) {
   if (Utils._.isPlainObject(field)) {
     return field.attribute;
   }
   return field;
 });