code: function inputRecord (type, record) {
    const clone = {};
    const recordTypes = this.recordTypes;
    const primaryKey = this.keys.primary;
    const isArrayKey = this.keys.isArray;
    const generateId = this.options.generateId;
    const fields = recordTypes[type];
  
    // ID business.
    const id = record[primaryKey];
    clone[idKey] = id ? id : generateId(type);
  
    for (const field in record) {
      if (field === primaryKey) continue;
      clone[field] = record[field];
    }
  
    for (const field of Object.getOwnPropertyNames(fields))
      if (!(field in record))
        clone[field] = fields[field][isArrayKey] ? [] : null;
  
    return clone;
  }
docs: Cast and assign values per field definition.