Skip to content

Commit

Permalink
Merge pull request #182 from AthennaIO/develop
Browse files Browse the repository at this point in the history
feat(command): add connection wait time to task
  • Loading branch information
jlenon7 authored Nov 20, 2024
2 parents 5a04150 + b296e9b commit d62c3de
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
6 changes: 4 additions & 2 deletions src/commands/DbSeedCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,15 @@ export class DbSeedCommand extends BaseCommand {
public async handle(): Promise<void> {
this.logger.simple('({bold,green} [ SEEDING DATABASE ])\n')

const task = this.logger.task()
const DB = Database.connection(this.connection)

if (this.getConfig('driver') === 'mongo') {
await Exec.sleep(1000)
task.addPromise('Connecting to database', async () => {
await Exec.sleep(5000)
})
}

const task = this.logger.task()
const dbName = await DB.getCurrentDatabase()

await DB.runSeeders({ task, classes: this.classes })
Expand Down
18 changes: 11 additions & 7 deletions src/commands/DbWipeCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,13 @@ export class DbWipeCommand extends BaseCommand {
const task = this.logger.task()

if (this.getConfig('driver') === 'mongo') {
await Exec.sleep(1000)
task.addPromise('Connecting to database', () => {
return Exec.sleep(5000)
})

const tables = await DB.getTables()
task.addPromise('Dropping all database tables', async () => {
const tables = await DB.getTables()

task.addPromise('Dropping all database tables', () => {
return Exec.concurrently(tables, table => DB.dropTable(table))
})
} else {
Expand All @@ -53,12 +55,14 @@ export class DbWipeCommand extends BaseCommand {
)
}

const dbName = await DB.getCurrentDatabase()
await task.run().finally(async () => {
const dbName = await DB.getCurrentDatabase()

await task.run().finally(() => DB.close())
await DB.close()

console.log()
this.logger.success(`Database ({yellow} "${dbName}") successfully wiped.`)
console.log()
this.logger.success(`Database ({yellow} "${dbName}") successfully wiped.`)
})
}

private getConfig(name: string, defaultValue?: any) {
Expand Down

0 comments on commit d62c3de

Please sign in to comment.