This commit is contained in:
Primakov Alexandr Alexandrovich
2025-05-08 15:48:02 +03:00
parent 48167530fd
commit 95bcaf3c5e
3 changed files with 13 additions and 9 deletions

View File

@@ -2,7 +2,3 @@ import 'dotenv/config';
// Connection URL
export const mongoUrl = process.env.MONGO_ADDR
console.log('=======================================================')
console.log('mongoUrl', mongoUrl)
console.log('=======================================================')

View File

@@ -1,15 +1,18 @@
const MDBClient = require('mongodb').MongoClient
import { MongoClient as MDBClient } from 'mongodb'
const { mongoUrl } = require('./const')
import { mongoUrl } from './const'
const dbInstanses = {
}
console.log('=======================================================')
console.log('mongoUrl', mongoUrl)
console.log('=======================================================')
const mongoDBConnect = async () => {
try {
const MongoClient = new MDBClient(mongoUrl, {
useUnifiedTopology: true,
})
const MongoClient = new MDBClient(mongoUrl, {})
const client = await MongoClient.connect()
console.log('Подключение к MongoDB успешно')
return client

View File

@@ -2,6 +2,11 @@ import mongoose from 'mongoose'
import { mongoUrl } from './const'
console.log('=======================================================')
console.log('mongoUrl2', mongoUrl)
console.log('=======================================================')
mongoose.connect(`${mongoUrl}`).then(() => {
console.log('Подключение к MongoDB успешно')
}).catch((err) => {