|
@@ -1,12 +1,9 @@
|
|
|
import Path from 'path'
|
|
import Path from 'path'
|
|
|
-import mongodb from '../../app/src/infrastructure/mongodb.js'
|
|
|
|
|
-import Mongoose from '../../app/src/infrastructure/Mongoose.js'
|
|
|
|
|
|
|
+import { db } from '../../app/src/infrastructure/mongodb.js'
|
|
|
import { fileURLToPath } from 'url'
|
|
import { fileURLToPath } from 'url'
|
|
|
|
|
|
|
|
const __filename = fileURLToPath(import.meta.url)
|
|
const __filename = fileURLToPath(import.meta.url)
|
|
|
const __dirname = Path.dirname(__filename)
|
|
const __dirname = Path.dirname(__filename)
|
|
|
-const { db } = mongodb
|
|
|
|
|
-const { getNativeDb } = Mongoose
|
|
|
|
|
|
|
|
|
|
class Adapter {
|
|
class Adapter {
|
|
|
constructor(params) {
|
|
constructor(params) {
|
|
@@ -26,8 +23,7 @@ class Adapter {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
async connect() {
|
|
async connect() {
|
|
|
- const nativeDb = await getNativeDb()
|
|
|
|
|
- return { db, nativeDb }
|
|
|
|
|
|
|
+ return { db }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
disconnect() {
|
|
disconnect() {
|
|
@@ -35,7 +31,6 @@ class Adapter {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
async getExecutedMigrationNames() {
|
|
async getExecutedMigrationNames() {
|
|
|
- const { db } = await this.connect()
|
|
|
|
|
const migrations = await db.migrations
|
|
const migrations = await db.migrations
|
|
|
.find({}, { sort: { migratedAt: 1 }, projection: { name: 1 } })
|
|
.find({}, { sort: { migratedAt: 1 }, projection: { name: 1 } })
|
|
|
.toArray()
|
|
.toArray()
|
|
@@ -43,7 +38,6 @@ class Adapter {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
async markExecuted(name) {
|
|
async markExecuted(name) {
|
|
|
- const { db } = await this.connect()
|
|
|
|
|
return db.migrations.insertOne({
|
|
return db.migrations.insertOne({
|
|
|
name,
|
|
name,
|
|
|
migratedAt: new Date(),
|
|
migratedAt: new Date(),
|
|
@@ -51,7 +45,6 @@ class Adapter {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
async unmarkExecuted(name) {
|
|
async unmarkExecuted(name) {
|
|
|
- const { db } = await this.connect()
|
|
|
|
|
return db.migrations.deleteOne({
|
|
return db.migrations.deleteOne({
|
|
|
name,
|
|
name,
|
|
|
})
|
|
})
|