Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async updateDatabase() {
// Download and extract the database package from npm
logger.info( `Downloading database update to ${this.tempFolder}` )
await remove( this.tempFolder )
await extract( databasePackage, this.tempFolder )
logger.info( 'Hot-patching database module' )
// Disconnect the Shabad OS database connection
await knex.destroy()
// Move across the updated npm database module
await move( this.tempFolder, DATABASE_FOLDER, { overwrite: true } )
// Reimport the database
//! Relies on knex being reinitialised globally
importFresh( '@shabados/database' )
}