src/common/mapper.js
function tableToMapping(table, key, ignore=['index']) {
  const now = new Date();
  const mapping = {
    created: now.toString(),
    fields: table.fields.filter(e => e.key !== key)
      .filter(e => !ignore.includes(e.key)),
    key: key,
    mapping: {}
  };
  table.records.forEach(row => {
    mapping.mapping[row[key]] = mapping.fields.map(e => row[e.key]);
  });
  return mapping;
}
function tableToMapping(table, key, ignore=['index']) {
  const now = new Date();
  const mapping = {
    created: now.toString(),
    fields: table.fields.filter(e => e.key !== key)
      .filter(e => !ignore.includes(e.key)),
    key: key,
    mapping: {}
  };
  table.records.forEach(row => {
    mapping.mapping[row[key]] = mapping.fields.map(e => row[e.key]);
  });
  return mapping;
}
function tableToMapping ( table , key , ignore = [ 'index' ] ) { const now = new Date ( ) ; const mapping = { created : now . toString ( ) , fields : table . fields . filter ( e => e . key !== key ) . filter ( e => ! ignore . includes ( e . key ) ) , key : key , mapping : { } } ; table . records . forEach ( row => { mapping . mapping [ row [ key ] ] = mapping . fields . map ( e => row [ e . key ] ) ; } ) ; return mapping ; }
Convert table to field mapping
@param {object} table - table
@param {object} key - key
@return {object} field mapping
Convert table to field mapping