Skip to content

Commit

Permalink
Merge pull request #188 from AthennaIO/develop
Browse files Browse the repository at this point in the history
chore(npm): update dependencies
  • Loading branch information
jlenon7 authored Jan 24, 2025
2 parents bc3ca8b + d4918f3 commit 5a1d974
Show file tree
Hide file tree
Showing 23 changed files with 947 additions and 628 deletions.
1,260 changes: 772 additions & 488 deletions package-lock.json

Large diffs are not rendered by default.

22 changes: 11 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@athenna/database",
"version": "5.9.0",
"version": "5.10.0",
"description": "The Athenna database handler for SQL/NoSQL.",
"license": "MIT",
"author": "João Lenon <[email protected]>",
Expand Down Expand Up @@ -76,18 +76,18 @@
"fast-deep-equal": "^3.1.3"
},
"devDependencies": {
"@athenna/artisan": "^5.3.0",
"@athenna/common": "^5.3.0",
"@athenna/config": "^5.1.0",
"@athenna/ioc": "^5.0.0",
"@athenna/logger": "^5.1.0",
"@athenna/test": "^5.2.0",
"@athenna/artisan": "^5.6.0",
"@athenna/common": "^5.7.0",
"@athenna/config": "^5.3.0",
"@athenna/ioc": "^5.1.0",
"@athenna/logger": "^5.3.0",
"@athenna/test": "^5.3.0",
"@athenna/tsconfig": "^5.0.0",
"@athenna/view": "^5.1.0",
"@athenna/view": "^5.3.0",
"@types/knex": "^0.16.1",
"@types/mongoose": "^5.11.97",
"@typescript-eslint/eslint-plugin": "^7.18.0",
"@typescript-eslint/parser": "^7.18.0",
"@typescript-eslint/eslint-plugin": "^8.21.0",
"@typescript-eslint/parser": "^8.21.0",
"better-sqlite3": "^9.6.0",
"commitizen": "^4.3.1",
"cz-conventional-changelog": "^3.3.0",
Expand All @@ -101,7 +101,7 @@
"husky": "^3.1.0",
"lint-staged": "^12.5.0",
"mongodb-memory-server": "^9.5.0",
"mongoose": "^7.8.3",
"mongoose": "^8.9.5",
"mysql2": "^3.12.0",
"pg": "^8.13.1",
"prettier": "^2.8.8"
Expand Down
18 changes: 0 additions & 18 deletions src/commands/DbSeedCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
* file that was distributed with this source code.
*/

import { Exec } from '@athenna/common'
import { Database } from '#src/facades/Database'
import { BaseCommand, Option } from '@athenna/artisan'

Expand Down Expand Up @@ -40,12 +39,6 @@ export class DbSeedCommand extends BaseCommand {
const task = this.logger.task()
const DB = Database.connection(this.connection)

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

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

await task
Expand All @@ -59,15 +52,4 @@ export class DbSeedCommand extends BaseCommand {
})
.finally(() => DB.close())
}

private getConfig(name: string, defaultValue?: any) {
return Config.get(
`database.connections.${
this.connection === 'default'
? Config.get('database.default')
: this.connection
}.${name}`,
defaultValue
)
}
}
7 changes: 1 addition & 6 deletions src/commands/DbWipeCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
* file that was distributed with this source code.
*/

import { Exec } from '@athenna/common'
import { Database } from '#src/facades/Database'
import { BaseCommand, Option } from '@athenna/artisan'

Expand All @@ -34,14 +33,10 @@ export class DbWipeCommand extends BaseCommand {
const DB = Database.connection(this.connection)

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

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

return Exec.concurrently(tables, table => DB.dropTable(table))
return tables.athenna.concurrently(table => DB.dropTable(table))
})
} else {
const migrationsTable = this.getConfig(
Expand Down
6 changes: 4 additions & 2 deletions src/database/DatabaseImpl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
*/

import type { Knex } from 'knex'
import { Path, Module, Options } from '@athenna/common'
import type { Connections, ConnectionOptions } from '#src/types'
import type { FakeDriver } from '#src/database/drivers/FakeDriver'
import { QueryBuilder } from '#src/database/builders/QueryBuilder'
import { Path, Module, Options, Macroable } from '@athenna/common'
import { ConnectionFactory } from '#src/factories/ConnectionFactory'
import type { MongoDriver } from '#src/database/drivers/MongoDriver'
import type { MySqlDriver } from '#src/database/drivers/MySqlDriver'
Expand All @@ -20,7 +20,7 @@ import type { Driver as DriverImpl } from '#src/database/drivers/Driver'
import type { Transaction } from '#src/database/transactions/Transaction'
import type { PostgresDriver } from '#src/database/drivers/PostgresDriver'

export class DatabaseImpl<Driver extends DriverImpl = any> {
export class DatabaseImpl<Driver extends DriverImpl = any> extends Macroable {
/**
* The connection name used for this instance.
*/
Expand All @@ -35,6 +35,8 @@ export class DatabaseImpl<Driver extends DriverImpl = any> {
* Creates a new instance of DatabaseImpl.
*/
public constructor(athennaDbOpts?: ConnectionOptions) {
super()

this.driver = ConnectionFactory.fabricate(
this.connectionName
) as unknown as Driver
Expand Down
15 changes: 10 additions & 5 deletions src/database/builders/QueryBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,20 @@
* file that was distributed with this source code.
*/

import type {
Collection,
PaginatedResponse,
PaginationOptions
import {
Macroable,
type Collection,
type PaginatedResponse,
type PaginationOptions
} from '@athenna/common'
import type { Operations } from '#src/types/Operations'
import type { Direction, ModelColumns } from '#src/types'
import type { Driver as DriverImpl } from '#src/database/drivers/Driver'

export class QueryBuilder<T = any, Driver extends DriverImpl = any> {
export class QueryBuilder<
T = any,
Driver extends DriverImpl = any
> extends Macroable {
/**
* The drivers responsible for handling database operations.
*/
Expand All @@ -26,6 +30,7 @@ export class QueryBuilder<T = any, Driver extends DriverImpl = any> {
* Creates a new instance of QueryBuilder.
*/
public constructor(driver: Driver, tableName: string) {
super()
this.driver = driver
this.driver.table(tableName)
}
Expand Down
2 changes: 1 addition & 1 deletion src/database/drivers/Driver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ export abstract class Driver<Client = any, QB = any> {
/**
* Sync a model schema with the driver.
*/
public abstract sync(schema: ModelSchema): Promise<void>
public abstract sync(schema: ModelSchema): Promise<any>

/**
* Create a new transaction.
Expand Down
Loading

0 comments on commit 5a1d974

Please sign in to comment.