Skip to content

Commit 7d15a6e

Browse files
authored
Merge pull request #184 from AthennaIO/develop
feat(command): wait for connection to be stablished
2 parents 2f6b3f6 + 35e03e1 commit 7d15a6e

File tree

4 files changed

+15
-11
lines changed

4 files changed

+15
-11
lines changed

package-lock.json

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@athenna/database",
3-
"version": "5.5.0",
3+
"version": "5.6.0",
44
"description": "The Athenna database handler for SQL/NoSQL.",
55
"license": "MIT",
66
"author": "João Lenon <lenon@athenna.io>",

src/commands/DbSeedCommand.ts

+11-7
Original file line numberDiff line numberDiff line change
@@ -41,19 +41,23 @@ export class DbSeedCommand extends BaseCommand {
4141
const DB = Database.connection(this.connection)
4242

4343
if (this.getConfig('driver') === 'mongo') {
44-
task.addPromise('Connecting to database', async () => {
45-
await Exec.sleep(5000)
44+
task.addPromise('Connecting to database', () => {
45+
return Exec.sleep(5000)
4646
})
4747
}
4848

49-
const dbName = await DB.getCurrentDatabase()
50-
5149
await DB.runSeeders({ task, classes: this.classes })
5250

53-
await task.run().finally(() => DB.close())
51+
await task.run().finally(async () => {
52+
const dbName = await DB.getCurrentDatabase()
53+
54+
await DB.close()
5455

55-
console.log()
56-
this.logger.success(`Database ({yellow} "${dbName}") successfully seeded.`)
56+
console.log()
57+
this.logger.success(
58+
`Database ({yellow} "${dbName}") successfully seeded.`
59+
)
60+
})
5761
}
5862

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

src/commands/DbWipeCommand.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ export class DbWipeCommand extends BaseCommand {
3030
public async handle(): Promise<void> {
3131
this.logger.simple('({bold,green} [ WIPING DATABASE ])\n')
3232

33-
const DB = Database.connection(this.connection)
3433
const task = this.logger.task()
34+
const DB = Database.connection(this.connection)
3535

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

0 commit comments

Comments
 (0)