Skip to content

Commit

Permalink
Merge pull request #184 from AthennaIO/develop
Browse files Browse the repository at this point in the history
feat(command): wait for connection to be stablished
  • Loading branch information
jlenon7 authored Nov 20, 2024
2 parents 2f6b3f6 + 35e03e1 commit 7d15a6e
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 11 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@athenna/database",
"version": "5.5.0",
"version": "5.6.0",
"description": "The Athenna database handler for SQL/NoSQL.",
"license": "MIT",
"author": "João Lenon <[email protected]>",
Expand Down
18 changes: 11 additions & 7 deletions src/commands/DbSeedCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,19 +41,23 @@ export class DbSeedCommand extends BaseCommand {
const DB = Database.connection(this.connection)

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

const dbName = await DB.getCurrentDatabase()

await DB.runSeeders({ task, classes: this.classes })

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

await DB.close()

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

private getConfig(name: string, defaultValue?: any) {
Expand Down
2 changes: 1 addition & 1 deletion src/commands/DbWipeCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ export class DbWipeCommand extends BaseCommand {
public async handle(): Promise<void> {
this.logger.simple('({bold,green} [ WIPING DATABASE ])\n')

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

if (this.getConfig('driver') === 'mongo') {
task.addPromise('Connecting to database', () => {
Expand Down

0 comments on commit 7d15a6e

Please sign in to comment.