Include schema package

This commit is contained in:
rijkvanzanten
2020-11-09 11:21:43 -05:00
parent ad56b8b556
commit 427bd8564e
24 changed files with 6457 additions and 1 deletions

View File

@@ -0,0 +1,14 @@
/**
* Extracts the length value out of a given datatype
* For example: `varchar(32)` => 32
*/
export default function extractMaxLength(type: string): null | number {
const regex = /\(([^)]+)\)/;
const matches = regex.exec(type);
if (matches && matches.length > 0 && matches[1]) {
return Number(matches[1]);
}
return null;
}