Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(command): wait for connection to be stablished #184

Merged
merged 1 commit into from
Nov 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading