Skip to content

Instantly share code, notes, and snippets.

@palanisamym14
Created March 29, 2021 14:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save palanisamym14/0b5d549c18d3bd0a743339a80ec5629a to your computer and use it in GitHub Desktop.
Save palanisamym14/0b5d549c18d3bd0a743339a80ec5629a to your computer and use it in GitHub Desktop.
[].map(itm=> ({...itm, column: itm.column.replace('msaRecord.', '').replace('msaData.','d_').replace('.', '_')}))
const data =[];
let key = 'CREATE TABLE TABLE (', val = 'VALUES(';
data.forEach(itm=>{
switch(itm.type){
case 'string':
key += `${itm.column.toLocaleUpperCase()} VARCHAR(${itm.width}),`;
break;
case 'int':
key += `${itm.column.toLocaleUpperCase()} INT,`;
break;
default:
break;
}
val +=':'+itm.column+',';
})
console.log(key+')'+val+')')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment