Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async checkDatabaseVersion() {
let version;
try {
// Using `raw` due to knex not having the SHOW command
const result = await this.knex.raw('SHOW server_version;');
// the version is inside the first row "server_version"
version = result.rows[0].server_version;
} catch (error) {
throw new Error(`Error reading version from PostgreSQL: ${error}`);
}
if (!versionGreaterOrEqualTo(version, this.minVer)) {
throw new Error(
`PostgreSQL version ${version} is incompatible. Version ${this.minVer} or later is required.`
);
}
}
}
async checkDatabaseVersion() {
let info;
try {
info = await new this.mongoose.mongo.Admin(this.mongoose.connection.db).buildInfo();
} catch (error) {
console.log(`Error reading version from MongoDB: ${error}`);
}
if (!versionGreaterOrEqualTo(info.versionArray, this.minVer)) {
throw new Error(
`MongoDB version ${info.version} is incompatible. Version ${this.minVer} or later is required.`
);
}
}
}