feathers-knex-modeler
Advanced tools
Comparing version 1.0.5 to 1.0.6
{ | ||
"name": "feathers-knex-modeler", | ||
"version": "1.0.5", | ||
"version": "1.0.6", | ||
"description": "This package allows you to easily extend a table while you are developing it without requiring you to drop tables.", | ||
@@ -5,0 +5,0 @@ "main": "src/index.js", |
@@ -69,17 +69,26 @@ /* eslint-disable no-console */ | ||
} | ||
async hasColumn (tableName, columnName) { | ||
async hasColumn (tableName, columnName, retries = 0) { | ||
const self = this | ||
const db = self.db | ||
tableName = tableName || self.name | ||
let col | ||
if (!_.isUndefined(columnName.name)) { | ||
col = columnName.name | ||
} else { | ||
col = columnName | ||
try { | ||
const db = self.db | ||
tableName = tableName || self.name | ||
let col | ||
if (!_.isUndefined(columnName.name)) { | ||
col = columnName.name | ||
} else { | ||
col = columnName | ||
} | ||
return db.schema.hasColumn(tableName, col) | ||
} catch (err) { | ||
retries++ | ||
if (retries > 5) { | ||
throw err | ||
} else { | ||
self.hasColumn(tableName, columnName, retries) | ||
} | ||
} | ||
return db.schema.hasColumn(tableName, col) | ||
} | ||
async waitForColumn (tableName, columnName) { | ||
const self = this | ||
await pWaitFor(() => self.hasColumn(tableName, columnName)) | ||
await pWaitFor(async () => self.hasColumn(tableName, columnName)) | ||
} | ||
@@ -201,4 +210,4 @@ alterColumn (column, option) { | ||
tableName = tableName || self.name | ||
let hasColumn = await self.hasTable(tableName) | ||
if (hasColumn === false) { | ||
let hasTable = await self.hasTable(tableName) | ||
if (hasTable === false) { | ||
return db.schema.createTable(self.name, function () { | ||
@@ -205,0 +214,0 @@ return true |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
15748
398