Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
getTableStructure: function(tableName, cb) {
var dbName = opts.database || 'main';
var rawSql = 'pragma '
+ knexString.escape(dbName)
+ '.table_info('
+ knexString.escape(tableName)
+ ');';
sqlite
.raw(rawSql)
.catch(cb)
.then(function(info) {
var structure = info.map(function(col) {
var parensAndContents = /\(.+\)/;
var sanitizedType = col.type
.toLowerCase()
.replace(parensAndContents, '');
return {
columnName: col.name,
isNullable: col.notnull !== 1,
columnKey: col.pk === 1 ? 'PRI' : null,
dataType: sanitizedType
};
getTableStructure: function(tableName, cb) {
var dbName = opts.database || 'main';
var rawSql = 'pragma '
+ knexString.escape(dbName)
+ '.table_info('
+ knexString.escape(tableName)
+ ');';
sqlite
.raw(rawSql)
.catch(cb)
.then(function(info) {
var structure = info.map(function(col) {
var parensAndContents = /\(.+\)/;
var sanitizedType = col.type
.toLowerCase()
.replace(parensAndContents, '');
return {
columnName: col.name,
isNullable: col.notnull !== 1,
columnKey: col.pk === 1 ? 'PRI' : null,